Skip to main content
You can send traces from LLM applications and AI agents to a Mezmo Pipeline with OpenTelemetry (OTel). Each span records one step, such as a model call, an agent turn, or a tool use, with its latency, token usage, and IDs. After the spans reach your Pipeline, you can filter, sample, and enrich them, then route them to the Destinations you already use. Mezmo receives these spans through the OpenTelemetry Source, the same OTLP endpoint you use for any other trace. Any library or framework that exports spans over OTLP/HTTP can send them, whichever LLM provider it calls.

Before You Begin

You need:
  • A Pipeline with an OpenTelemetry Source. Connect the Source’s Traces output to the Processors and Destinations that should receive your spans.
  • A Mezmo ingestion key. In the Mezmo Web App, go to Settings > Organization > API Keys.
  • An application that emits OpenTelemetry spans for its LLM calls, through an instrumentation library, a framework with built-in tracing, or your own code. See Choose an Instrumentation Library.
Every sender uses these connection settings:
Settings that take a base endpoint, such as OTEL_EXPORTER_OTLP_ENDPOINT or the Collector’s otlphttp exporter, use https://logs.mezmo.com/otel without a path, because the exporter adds /v1/traces for you. Settings that take the full traces URL, such as OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, a Spring Boot management.otlp.tracing.endpoint, or a Cloudflare destination, use https://logs.mezmo.com/otel/v1/traces.

Choose an Instrumentation Library

LLM tracing libraries name span attributes according to one of several semantic conventions. The convention decides which attribute names reach your Pipeline, so note which one your library uses before you configure Processors: These libraries and frameworks emit OpenTelemetry spans for LLM calls and agent activity. Each one has its own setup, so follow its documentation for installation and options, and use the exporter settings on this page to send its spans to Mezmo.
Other libraries that export OTLP over HTTP also work. When no library covers your provider, add the GenAI attributes to your own spans.

Configure the OpenTelemetry Exporter

The OpenTelemetry SDK reads its exporter settings from standard environment variables, so most applications can send traces to Mezmo without code changes to the exporter. Set these variables in the environment where your application runs:
  • OTEL_SERVICE_NAME becomes the service.name resource attribute. Mezmo uses it to set the app annotation on each span, so pick a name that identifies the application or agent.
  • OTEL_SEMCONV_STABILITY_OPT_IN affects only instrumentation libraries that read it. Some libraries emit older GenAI attribute names unless you set it. If you already set this variable for other features, add gen_ai_latest_experimental to its comma-separated value.
If your services already send telemetry to an OpenTelemetry Collector that exports to Mezmo, point the application at the Collector’s OTLP receiver instead, and let the Collector forward the spans.

Send Traces from Your Application

Instrument an LLM Client Library

Instrumentation libraries patch an LLM client so that each call produces a span, without changes to the code that makes the call. These examples trace OpenAI calls in Python. The same pattern works for the other providers and frameworks that each library supports.
  1. Set the environment variables from Configure the OpenTelemetry Exporter.
  2. Install the libraries and enable the instrumentation before your first model call:
This library records prompts and responses only when you set OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true.
  1. Run the application. Each model call produces a span on the Traces output of your OpenTelemetry Source.

Trace Strands Agents

Strands Agents emits spans for each agent invocation, model call, and tool use. It reads the standard OTEL_EXPORTER_OTLP_* variables, so set the variables from Configure the OpenTelemetry Exporter, including OTEL_SEMCONV_STABILITY_OPT_IN="gen_ai_latest_experimental". Without that variable, Strands emits an older version of the GenAI attributes.
This example uses the default Amazon Bedrock model provider, so it also needs AWS credentials with Bedrock access.

Trace Cloudflare Agents

Cloudflare Agents running on Workers emit GenAI spans through Workers Observability. Workers export telemetry to a destination that you create in the Cloudflare dashboard, so you set the Mezmo endpoint and ingestion key on that destination instead of in environment variables.
  1. In the Cloudflare dashboard, go to Observability > Destinations and select Add destination.
  2. Configure the destination:
    • Destination name: a name such as mezmo-traces.
    • Destination type: Traces.
    • OTLP endpoint: https://logs.mezmo.com/otel/v1/traces.
    • Custom headers: a header named apikey with your Mezmo ingestion key as its value.
  3. Enable traces in your Worker’s Wrangler configuration and list the destination by name:
  4. If your agent calls the Vercel AI SDK directly, wrap it with wrapAISDK() so that model calls produce spans with GenAI attributes. Cloudflare instruments its supported agent frameworks automatically.
  5. Redeploy the Worker. Spans can take several minutes to reach your Pipeline. The destination’s status in the Cloudflare dashboard shows whether delivery succeeded.

Trace Claude SDK Calls

The Claude SDK emits OpenTelemetry spans for Messages API requests, tool runner tool uses, and Claude Managed Agents session requests. It sends them to the tracer provider that your application registers. Claude SDK tracing is in beta. See Set up OpenTelemetry with the Claude SDK for other languages and every option.
  1. Install the Claude SDK, the OpenTelemetry SDK, and the OTLP HTTP exporter:
  2. Set the environment variables from Configure the OpenTelemetry Exporter.
  3. Register a tracer provider before your first Claude call:
  4. Run the application. Each request produces an anthropic.messages.create span on the Traces output of your OpenTelemetry Source.
With content_mode="content", spans carry the full prompts and responses that your application exchanges with Claude. Mezmo then processes and stores that content under your Pipeline’s Destinations and their retention settings. Use the default metadata_only mode when prompts can contain data that must not leave your application.

Trace Claude API and Managed Agents Activity

The Claude API can also send spans for every request in your Claude Console organization, including model runs, server tool uses, and Claude Managed Agents turns, without code changes. You need the admin role in the Claude Console organization. Claude API tracing is in beta. See Set up OpenTelemetry with the Claude API for the full reference.
  1. In the Claude Console, open the OpenTelemetry settings page and select Add destination.
  2. In Provider, select Custom.
  3. In OTLP endpoint URL, enter https://logs.mezmo.com/otel.
  4. In Request headers, add a header named apikey with your Mezmo ingestion key as its value.
  5. In Content mode, select Metadata only or Full content.
  6. In Workspaces, select the workspaces whose spans Mezmo should receive.
  7. Select Add destination.
  8. In the destination’s More actions menu, select Test.
The test sends an anthropic.test span to your OpenTelemetry Source. Spans from the Claude API carry the resource attribute service.name set to claude-platform, so they arrive with the app annotation claude-platform. If you also trace the Claude SDK, each Messages API request has both an SDK span and an API span. To count tokens once per request, follow Anthropic’s guidance on counting tokens.

Send Langfuse Spans to Mezmo

The Langfuse Python SDK v3 and later and the JS SDK v4 and later are built on OpenTelemetry and attach their span processor to the global tracer provider. To send the same spans to Mezmo as well as to Langfuse, add a Mezmo exporter to that provider:
See Using Langfuse with an existing OpenTelemetry setup for filtering and isolation options.

Add GenAI Attributes to Your Own Spans

When your LLM provider or agent framework has no tracing of its own, create the spans yourself and set the GenAI attributes on them. This example records one chat call with the OpenTelemetry Python SDK:
For the full list of attributes and span names, see the GenAI semantic conventions for spans.

Work with GenAI Spans in Your Pipeline

The OpenTelemetry Source passes each span through in its OpenTelemetry JSON form, with GenAI attributes under message.record.attributes. A model call span looks like this on the Traces output:
Processor data fields start at the event’s message, and attribute names that contain dots go in quotation marks. See Syntax for Editing Pipeline Component Configuration Values for details. Use these data fields when you configure Processors: These data fields follow the OpenTelemetry GenAI convention. Spans from OpenInference and Langfuse carry the same information under other names: Attribute values often arrive as strings, so convert token counts to numbers before you add or compare them. For the complete event shape, see OpenTelemetry Event Shapes. To keep GenAI spans apart from your other traces, add a Route Processor that matches on gen_ai.operation.name, or on openinference.span.kind for OpenInference spans. To reduce trace volume, use the experimental Trace Sampling Processor, which can sample traces with errors at a different rate from other traces. To forward the spans to another tool that accepts OTLP, connect them to an OpenTelemetry Destination.

Troubleshoot Trace Delivery