# Traces

> Send OpenTelemetry traces from your agents to otel.clonvo.com and see gateway calls inside them: setup, pricing and retention.

Send OpenTelemetry traces from your agents to Clonvo with the same API key you call models with. Each run shows up under **Traces** in the dashboard as a waterfall of its steps, with the model and tool calls it made through Clonvo inside it, their tokens and their cost.

Clonvo reads the attributes agent frameworks already emit: the OpenTelemetry GenAI conventions (`gen_ai.*`), OpenInference (`llm.*`, `input.value`), the Vercel AI SDK (`ai.*`) and Langfuse (`langfuse.*`). Spans are grouped as LLM calls, tool calls, agents and other steps, and their inputs and outputs are kept with the trace. Prompts and completions are shown as messages, with tool calls and their results, in any of those formats or OpenAI’s and Anthropic’s. The JSON is one click away.

## Secrets are masked

Before a span is stored, Clonvo masks secrets in its name, attributes, inputs, outputs and events: API keys from OpenAI, Anthropic, OpenRouter, Clonvo, Stripe, GitHub, Slack, Google, Hugging Face and others, `Bearer` and `Basic` credentials, `key=value` pairs such as `password=…` or `api_key=…`, AWS access key ids, JWTs, PEM private keys and payment card numbers. Attributes whose name suggests a secret, such as `password`, `token`, `api_key`, `authorization` or `cookie`, are masked whatever their value. Token counts like `gen_ai.usage.input_tokens` are kept. Masked values read `[REDACTED:<kind>]`.

## Endpoint

|  |  |
| --- | --- |
| Endpoint | `https://otel.clonvo.com` (traces go to `/v1/traces`) |
| Protocol | OTLP over HTTP, protobuf or JSON, optionally gzip |
| Authentication | `x-api-key: <key>` or `Authorization: Bearer <key>` |

gRPC isn’t supported. Set your exporter’s protocol to `http/protobuf` or `http/json`.

## Set up with environment variables

Most OpenTelemetry SDKs read these variables, so an agent that already exports traces only needs its environment changed:

```bash
OTEL_EXPORTER_OTLP_ENDPOINT=https://otel.clonvo.com
OTEL_EXPORTER_OTLP_HEADERS="x-api-key=<your Clonvo key>"
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
```

The exporter adds `/v1/traces` to the endpoint. If you set `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` instead, give the full URL: `https://otel.clonvo.com/v1/traces`.

## Vercel AI SDK

Start the OpenTelemetry Node SDK with an OTLP exporter, then turn on telemetry for each call:

```bash
npm install @opentelemetry/sdk-node @opentelemetry/exporter-trace-otlp-proto
```

```ts
import { NodeSDK } from "@opentelemetry/sdk-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";

// Reads OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS.
const sdk = new NodeSDK({ serviceName: "my-agent", traceExporter: new OTLPTraceExporter() });
sdk.start();
```

```ts
const result = await generateText({
  model,
  prompt: "Summarize today’s support tickets",
  experimental_telemetry: { isEnabled: true, metadata: { sessionId: "chat-123" } },
});
```

`ai.generateText` spans show up as agent steps, `ai.generateText.doGenerate` spans as LLM calls and `ai.toolCall` spans as tool calls. In Next.js, register the SDK in `instrumentation.ts`.

## Python

```bash
pip install opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
```

```python
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter

# Reads OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS.
provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
```

Then add the instrumentation for your framework. OpenInference has instrumentors for the OpenAI SDK, the OpenAI Agents SDK, LangChain, LlamaIndex, CrewAI and others:

```python
from openinference.instrumentation.openai import OpenAIInstrumentor

OpenAIInstrumentor().instrument()
```

Short scripts should call `provider.shutdown()` before they exit, so the last batch is sent.

## Gateway calls inside your traces

When a request to Clonvo carries a W3C `traceparent` header, Clonvo adds the call to that trace as a span under the span that made it. The span has the model or tool that ran, the provider, tokens, latency and what was charged, and links to the request in **Activity**.

OpenTelemetry’s HTTP instrumentation adds `traceparent` to outgoing requests. To add it yourself:

```bash
traceparent: 00-<32 hex trace id>-<16 hex parent span id>-01
```

Gateway calls don’t count as events. They’re billed as requests, as they are without tracing.

## Sessions and users

Clonvo shows each trace’s session. Open a session to read it as a conversation: each run in order, with the user’s message, the tools the agent called and its answer. Every step links to its span in the trace. For the session id, Clonvo reads `session.id`, `gen_ai.conversation.id`, `langfuse.session.id` and the AI SDK’s `metadata.sessionId`. For the user, it reads `user.id`, `enduser.id`, `langfuse.user.id` and the AI SDK’s `metadata.userId`.

## Pricing

Each span is one event. Every organization gets 30,000 events a month at no cost. After that, events cost $5 per 100,000, paid from [credits](https://clonvo.com/docs/credits.md). The count resets on the 1st of each month (UTC), and **Traces** in the dashboard shows this month’s events.

Once an organization has used its free events and has no credits, exports are rejected with `402` until credits are added. OpenTelemetry exporters don’t retry a `402`, so those spans are dropped.

## Retention

Spans are kept for 30 days on Free and 90 days on Pay as you go and Enterprise, counted from when each span started. The plan at the time a span arrives decides how long it’s kept. Spans can start up to 30 days before they’re exported. Older spans are rejected.

## Limits

| Limit | Value |
| --- | --- |
| Request body | 8 MB (32 MB after decompression) |
| Spans per request | 10,000 |
| Export requests per key | 600 a minute |
| Input, output or attribute value kept | 64 KB each |

## Responses

Clonvo answers as the OTLP/HTTP specification describes, so exporters retry only what can succeed later.

| Status | Meaning |
| --- | --- |
| `200` | Accepted. A `partialSuccess` lists spans that were rejected, such as spans with invalid ids or start times outside the accepted window. |
| `400` | The body isn’t valid OTLP. |
| `401`, `403` | The key is missing, invalid or disabled. |
| `402` | The free events are used up and the organization has no credits. |
| `413` | The request is too large. Lower `OTEL_BSP_MAX_EXPORT_BATCH_SIZE`. |
| `415` | The content type or encoding isn’t supported. |
| `429`, `503` | Retry after the `Retry-After` header. Exporters do this for you. |
