respan-instrumentation-anthropic
Respan instrumentation for the Anthropic Python SDK.
pip install 'respan-instrumentation-anthropic[instruments]'
import os
from anthropic import Anthropic
from respan import Respan
from respan_instrumentation_anthropic import AnthropicInstrumentor
respan = Respan(
api_key=os.environ["RESPAN_API_KEY"],
instrumentations=[AnthropicInstrumentor()],
)
with Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"]) as client:
message = client.messages.create(
model=os.environ["ANTHROPIC_MODEL"],
max_tokens=64,
messages=[{"role": "user", "content": "Write one line about tracing."}],
)
respan.flush()
The native adapter observes stable and beta messages.create(), available
messages.parse(), raw create(stream=True), and helper messages.stream()
for sync and async clients. It preserves native Message, Stream, parsed models,
and stream-manager objects. Streams are observed as the caller consumes them;
closing early does not drain the response to obtain a final message.
Available beta.sessions.events.stream() APIs are observed as agent spans.
Final native input/output events and source usage are retained; preview deltas
are not appended twice. Instrumentation does not create sessions, deploy agents,
or execute remote tools. Transmitted tool definitions, arguments, results, IDs,
thinking/signature blocks, schemas, and complete histories remain in their native
content. Model tool requests and historical tool results do not imply a locally
observed tool execution span.
Remaining native request options, including beta, thinking, structured-output,
and context-management configuration, are captured under
respan.metadata.anthropic.request. Native max tokens, temperature, and top-p
also use their GenAI attributes. Credential header values are redacted.
Content capture defaults to enabled. Disable it with
AnthropicInstrumentor(capture_content=False), TRACELOOP_TRACE_CONTENT=false,
RESPAN_TRACE_CONTENT=false, or an OTel context using the canonical Respan
ENABLE_CONTENT_TRACING_KEY=False (legacy trace_content=False also works).
General and LLM suppression skip tracing.
Capture policy narrows throughout the call, including observed active/finished
ancestors and stream consumption. Unknown local parent carriers fail closed.
Temporary veto contexts latch before detach. The observer retains at most 4096
bodyless finished ancestry records; older unknown local ancestry fails closed.
Credential values are redacted while schema property names remain intact.
Sampling is applied before content serialization. Telemetry faults do not change
native SDK outcomes or resource cleanup.
Multiple instrumentors with the same configuration share patches until the final
owner deactivates. Conflicting configurations remain inactive. Deactivation
restores only this adapter's wrappers and retains foreign wrappers/processors.
The SDK is optional; install the instruments extra when needed. Support starts
at Anthropic 0.39.0. Newer optional parse, beta helper, and managed-session APIs
are discovered when the installed SDK exposes them.
Controlled native examples live in python/tracing/anthropic in
respan-example-projects.
Metadata
Release files for respan-instrumentation-anthropic 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| respan_instrumentation_anthropic-1.2.0.tar.gz | 14.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| respan_instrumentation_anthropic-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.9 kB
Release files / respan_instrumentation_anthropic-1.2.0.tar.gz
| Download URL | respan_instrumentation_anthropic-1.2.0.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
154cd0397e9e9c5338354ada5684e236fed2609b0fcb85cc5a5f0873077e915e
|
|
BLAKE2b-256 checksum How to use checksums |
25d24702d59d1962dfdc184d7264355c72ec7bb71838051a95d8e91c8cdeda96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / respan_instrumentation_anthropic-1.2.0-py3-none-any.whl
| Download URL | respan_instrumentation_anthropic-1.2.0-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97462d2d84f12651d0f6f5e8c76f8d335cffe562c37220cd3d8235adffefaa12
|
|
BLAKE2b-256 checksum How to use checksums |
21f9fe333077f48e518d0627b54c9481c70781a87fe0dd0370439b5e89de01c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency log