Learning resourcesReviewed · Anthropic

Set up OpenTelemetry with the Anthropic SDK

This Anthropic guide helps application developers trace Claude requests and tool activity, but the beta feature's settings and trace format can change incompatibly. It covers Python, TypeScript, C#, Go, Java, PHP and Ruby, using an application-configured OpenTelemetry exporter to send trace records to an observability platform.

Researched 15 Nov 2026

In short.

This Anthropic setup guide is for developers adding Claude activity to application traces, but its beta interfaces can change in ways that break integrations and dashboards. It explains how to register a tracer provider, inspect spans locally and export them to an observability platform across seven SDK languages. Important integration details include content capture defaults, configuration overrides, streaming behavior, trace propagation and differences between SDK and API tracing. Runtime behavior, performance and backend compatibility were not assessed; costs and reuse rights are not established by the page.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete selected page at [https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk.md], including installation, all seven language examples, configuration defaults and precedence, streaming, sandbox workers, propagation, user identification, troubleshooting and availability. It includes the beta compatibility notice, privacy cautions and duplicate-header warning. The page was captured on 15 November 2026 at 07:55:57.039 UTC. Linked pages, repositories, packages, exporter instructions and issue discussions are excluded. No examples or integrations were executed; runtime behavior, performance, pricing and reuse rights remain unverified or unknown as specified.

The overview

Resource identity

This is Anthropic's documentation guide for enabling OpenTelemetry tracing in its SDKs. The selected source is the complete page at [https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk.md]. It teaches an integration feature rather than providing a standalone monitoring application.

OpenTelemetry spans are records of individual operations that can be grouped into a trace. Here, the SDK records requests and tool executions, while the application's exporter sends those records to an observability destination.

Practical assessment

The guide provides concrete implementation detail: installation instructions, tracer registration, console exporters, configuration options and troubleshooting for seven languages. Its strongest practical value is explaining how Claude SDK operations can fit into traces that an application already produces.

The main tradeoff is compatibility risk during beta. Anthropic warns that SDK updates can rename spans, attributes, options and environment variables, potentially breaking application code, queries and dashboards. The page recommends pinning SDK versions. No execution results or performance measurements establish how a particular deployment will behave.

Who it helps

The guide is relevant to developers and platform engineers who need to follow Claude requests and tool activity through an application. Beginners can start with spans printed to a console; teams already using OpenTelemetry can connect the SDK to their existing tracer provider and exporter.

There is additional guidance for streaming applications, MCP integrations and Managed Agents self-hosted sandboxes. The sandbox environment-worker instructions apply specifically to Python, TypeScript and Go.

Documented capabilities

The SDK emits spans for requests it sends and tool uses executed by its tool runner. Configuration supports selecting a tracer provider, linking calls through gen_ai.conversation.id, enabling prompt and response capture, changing content limits, controlling propagation and disabling spans for an individual client.

The default content mode is metadata_only. Capturing prompts and responses requires content mode, and the documented default content limit is 0.75 MB per span. Conversation IDs are exported in both modes, so the page warns against putting personal data or secrets in them.

The page states that SDK tracing is beta on every model. Messages API support is listed across the Claude API, Amazon Bedrock, Bedrock's bedrock-runtime interface, Claude Platform on AWS, Google-managed Claude Models on Google Cloud and Microsoft Foundry. Managed Agents support is listed for the Claude API and Claude Platform on AWS.

Using it

Requirements and dependencies

The setup requires the relevant Anthropic SDK and an OpenTelemetry tracer provider with an exporter. The page supplies installation instructions for Python, TypeScript, C#, Go, Java, PHP and Ruby. Its Java instructions specify anthropic-java 3.8.0 or later; most other installation commands request the latest available package without establishing a minimum compatible version.

For Java tracing or propagation failures caused by dependency resolution, the troubleshooting table requires opentelemetry-api 1.57.0 or later. C# tracer configuration must subscribe to the com.anthropic.sdk.csharp* source. The Go, Java and PHP examples explicitly register propagators for trace context and baggage.

Sending spans beyond the console requires an exporter configured for the chosen observability platform. A self-hosted sandbox also needs network access to that platform or an OpenTelemetry Collector. Backend-specific setup and application runtime minimums are not fully established by this page.

How tracing works

Spans originate inside the application running the SDK. A registered tracer provider creates and processes them, and an exporter delivers them to the destination. Calling the SDK within an application span allows related SDK operations to appear within the application's trace.

For outgoing requests, the SDK uses the application's propagator to send trace context in headers such as traceparent. If that propagator includes baggage, those key-value pairs are sent too. Registering only the W3C trace context propagator omits baggage. A user.id baggage entry can identify an end user on API spans; the page recommends opaque IDs and says the API drops user.id values containing an email address.

In Managed Agents, SDK tracing covers requests sent by application code. Agent model requests and tool calls use API tracing, while a self-hosted sandbox's environment worker emits its own tool and request spans beneath an anthropic.environment.work span for each work item.

For MCP calls, some client libraries can pass trace context to a server through _meta. The page identifies Python mcp version 2.0 onward and C# ModelContextProtocol as doing this; it says the TypeScript, Go, Java, Ruby and PHP MCP SDKs do not do so automatically. The server must read that context to attach its spans.

Setup path

The documented sequence is to install or upgrade the Anthropic SDK, add OpenTelemetry dependencies if needed, and register a tracer provider before the first call to be traced. The initial examples use a console or logging exporter. To send spans to an observability platform, replace that exporter with an OTLP exporter configured for the destination.

Configuration can be supplied in code or through supported environment variables. Supplying the client-level OpenTelemetry configuration overrides its environment-variable configuration as a whole: omitted nested keys return to their defaults. The Python example preserves existing settings when adding a conversation ID through with_options().

Java reads these environment settings when the client is built with fromEnv(), and the documented Java system properties take precedence over environment variables. The page links to language-specific exporter documentation, whose contents are outside the selected scope.

Documented example

The Python example installs anthropic and opentelemetry-sdk, constructs a TracerProvider, attaches SimpleSpanProcessor(ConsoleSpanExporter()), and registers it through trace.set_tracer_provider(). It then creates an Anthropic client and calls client.messages.create with the model identifier claude-opus-5-5, max_tokens set to 1024 and the user message Hello, Claude.

The page says the console shows an anthropic.messages.create span. A later example enables content capture and assigns conversation ID conv_42 while preserving the client's existing tracing options. These examples were not executed, so their output and compatibility were not independently observed.

Assessment & evidence

Limitations and integration traps

Streaming spans end only when the stream is fully read or closed, so an application that stops reading early must close it. Capturing a streamed response in content mode requires the documented streaming helper for the language. Spans started during the read loop are siblings of the SDK span; wrapping both the request and loop in an application span groups them together.

The page warns that TypeScript applications using @opentelemetry/instrumentation-undici, including through @opentelemetry/auto-instrumentations-node, should disable SDK propagation to avoid duplicate traceparent headers caused by the linked instrumentation bug. That bug's current status was not assessed. The documented C# propagation workaround changes the process-wide DistributedContextPropagator and affects every HttpClient.

SDK and API request spans can have the same name. The guide recommends distinguishing them through span kind or service.name, and disabling one instrumentation source when another library already traces the SDK. Export reliability, retry coverage, performance overhead and compatibility with particular backends remain unassessed.

Fit and tradeoffs

Based on the documented architecture, the guide is a strong fit for teams already using OpenTelemetry: the SDK can use their registered tracer provider while normal request calls remain the same. Teams starting without telemetry infrastructure also need to configure an exporter and destination.

The practical adoption decision depends on tolerating beta changes and choosing which application data may leave through telemetry. Version pinning, explicit content settings and checking propagation against existing HTTP instrumentation directly address risks described by the page. There is no evidence here to quantify diagnostic benefit or operational overhead.

Related approaches

The page links to API-side tracing for visibility into Claude API activity at [https://platform.claude.com/docs/en/manage-claude/opentelemetry/api]. That covers another part of the request path; the linked guide's setup and behavior were not assessed.

For applications already instrumented by another library, the documented options allow disabling SDK spans or SDK propagation to reduce duplication. Console export provides a local inspection path before configuring remote export. The page compares no competing monitoring products, so relative capabilities and costs are unknown.

Evidence and confidence

The evidence is the complete Anthropic documentation page at [https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk.md]. It supports the described configuration defaults, language examples, availability statements, streaming rules and troubleshooting guidance.

The page contains documentation examples rather than observed execution results. No code was run, no spans were inspected and no observability backend was connected. Linked references, package contents and the external bug report were not assessed, so those destinations provide no additional established findings here.

Access & freshness

Costs

The page provides no tracing price, Claude API usage rates, observability-platform prices or free allowance. The total cost is unknown. Any applicable API, telemetry ingestion, storage and retention charges would need to be established separately.

No measurements quantify tracing overhead or exported data volume. The 0.75 MB default content limit is a per-span content setting, not a billing estimate or measured storage requirement.

Rights and data handling

The selected page does not state a licence or redistribution permission for its documentation, examples or referenced SDK packages. Their reuse and redistribution terms are unknown from this evidence.

Content mode can export prompts and responses, while conversation identifiers and propagated baggage create additional data-handling considerations even with metadata_only selected. The page does not establish the chosen observability platform's access controls, retention rules or contractual terms.

Freshness and version sensitivity

The supplied page was captured on 15 November 2026 at 07:55:57.039 UTC. It does not establish a publication date or last-update date.

Its beta warning makes SDK-version compatibility especially important. Several installation commands request the latest version, but the page also advises pinning dependencies to control when breaking changes are adopted. Compatibility with releases after capture and the current status of linked issues are unknown.

Suggested next steps

Start with the example for your application language and a console exporter. Register the tracer provider before making a request, choose and pin an SDK version, and inspect whether SDK spans nest within your application traces. For streaming, check both full consumption and early closure.

Before enabling remote export, choose a content mode, review conversation identifiers and baggage, and configure the destination's exporter. Check whether existing HTTP or SDK instrumentation already creates spans or propagation headers, including the documented TypeScript undici conflict.

Establish applicable pricing and reuse terms separately. For a deployment decision, verify span delivery, content handling, streaming behavior and overhead in the intended application and backend; those outcomes remain unassessed.

Evidence for this report

selected-page.txtselected · checked 2026-11-15