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.
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.
- Python
- Node.js
- Java
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_NAMEbecomes theservice.nameresource attribute. Mezmo uses it to set theappannotation on each span, so pick a name that identifies the application or agent.OTEL_SEMCONV_STABILITY_OPT_INaffects 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, addgen_ai_latest_experimentalto its comma-separated value.
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.- Set the environment variables from Configure the OpenTelemetry Exporter.
- Install the libraries and enable the instrumentation before your first model call:
- OpenTelemetry
- OpenInference
- OpenLLMetry
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true.- 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 standardOTEL_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.
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.- In the Cloudflare dashboard, go to Observability > Destinations and select Add destination.
-
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
apikeywith your Mezmo ingestion key as its value.
- Destination name: a name such as
-
Enable traces in your Worker’s Wrangler configuration and list the destination by name:
-
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. - 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.-
Install the Claude SDK, the OpenTelemetry SDK, and the OTLP HTTP exporter:
- Set the environment variables from Configure the OpenTelemetry Exporter.
-
Register a tracer provider before your first Claude call:
-
Run the application. Each request produces an
anthropic.messages.createspan on the Traces output of your OpenTelemetry Source.
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.- In the Claude Console, open the OpenTelemetry settings page and select Add destination.
- In Provider, select Custom.
- In OTLP endpoint URL, enter
https://logs.mezmo.com/otel. - In Request headers, add a header named
apikeywith your Mezmo ingestion key as its value. - In Content mode, select Metadata only or Full content.
- In Workspaces, select the workspaces whose spans Mezmo should receive.
- Select Add destination.
- In the destination’s More actions menu, select Test.
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: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:Work with GenAI Spans in Your Pipeline
The OpenTelemetry Source passes each span through in its OpenTelemetry JSON form, with GenAI attributes undermessage.record.attributes. A model call span looks like this on the Traces output:
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.

