telemetry-dev-anthropic
Anthropic Claude SDK instrumentation for telemetry.dev. It wraps the official anthropic Python SDK and emits telemetry.dev generation spans through telemetry-dev.
Install
pip install telemetry-dev-anthropic
Initialize the core SDK first:
import telemetry_dev
telemetry_dev.init(
api_key="td_live_...",
service_name="my-service",
)
Per-client wrapping
from anthropic import Anthropic
from telemetry_dev_anthropic import wrap_anthropic
client = wrap_anthropic(Anthropic())
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Tell me a joke about OpenTelemetry"}],
)
wrap_anthropic also supports AsyncAnthropic, AnthropicBedrock, AsyncAnthropicBedrock, AnthropicVertex, and AsyncAnthropicVertex clients.
Global instrumentation
from anthropic import Anthropic
from telemetry_dev_anthropic import instrument_anthropic, uninstrument_anthropic
instrument_anthropic()
try:
client = Anthropic()
client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
finally:
uninstrument_anthropic()
Instrumented surfaces
client.messages.create(...)client.messages.create(..., stream=True)client.messages.stream(...)context managers, sync and async
The integration maps native Anthropic request and response shapes directly into telemetry.dev fields. It does not normalize messages into another schema.
Streaming
Native Anthropic stream events pass through unmodified. The span records time to first chunk on the first received event, merges usage from message_start and message_delta, aggregates text, tool-use JSON, and thinking blocks, and ends on stream exhaustion, close, context-manager exit, or error.
messages.stream() starts the span when the context manager is entered, because that is when the Anthropic SDK opens the HTTP stream.
Bedrock and Vertex
Class instrumentation covers Bedrock and Vertex clients because the Anthropic SDK reuses the same Messages and AsyncMessages resource classes. Provider attribution is recorded as aws.bedrock or gcp.vertex_ai when the client class identifies those runtimes.
Limitations
client.beta.messagesis not instrumented.messages.parse()andmessages.count_tokens()are not instrumented.with_raw_responsesnapshots bound methods; wrap or instrument clients before creating raw-response wrappers.- Unconsumed streams end spans only on exhaustion, close, context-manager exit, or error.
Metadata
Release files for telemetry-dev-anthropic 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| telemetry_dev_anthropic-0.1.1.tar.gz | 8.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| telemetry_dev_anthropic-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.6 kB
Release files / telemetry_dev_anthropic-0.1.1.tar.gz
| Download URL | telemetry_dev_anthropic-0.1.1.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f8a11344b88e71dabaa2511038dbc8cd57f89268ccaf9a4e508c5aac39c170b
|
|
BLAKE2b-256 checksum How to use checksums |
6f68e1a3cc65e1ff191410638cdef944d45d522ccd6d4b4bf497c5506b6f879c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / telemetry_dev_anthropic-0.1.1-py3-none-any.whl
| Download URL | telemetry_dev_anthropic-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a01dd1906a4a464db7f79429611a456d3b7784b26fa39c8627180f1666d6108
|
|
BLAKE2b-256 checksum How to use checksums |
8d038b81d460b59ec7aa0f14febfaf35fd9a3ea07cc4cca622fa86c067fad3f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|