OpenTelemetry Anthropic instrumentation
Project description
This library allows tracing LLM requests made by the Anthropic Python SDK.
Installation
pip install opentelemetry-instrumentation-genai-anthropic
If you don’t have an Anthropic application yet, try our examples which only need a valid Anthropic API key.
Check out the zero-code example for a quick start.
Usage
This section describes how to set up Anthropic instrumentation if you’re setting OpenTelemetry up manually. Check out the manual example for more details.
from opentelemetry.instrumentation.genai.anthropic import AnthropicInstrumentor
import anthropic
# Instrument Anthropic
AnthropicInstrumentor().instrument()
# Use Anthropic client as normal
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude!"}
]
)
Configuration
Capture Message Content
By default, prompts and completions are not captured. To capture message content, set the environment variable OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT to one of NO_CONTENT, SPAN_ONLY, EVENT_ONLY, or SPAN_AND_EVENT:
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_AND_EVENT
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opentelemetry_instrumentation_genai_anthropic-1.0b0.tar.gz.
File metadata
- Download URL: opentelemetry_instrumentation_genai_anthropic-1.0b0.tar.gz
- Upload date:
- Size: 50.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7849e0615e6b7424f683b90bfef90765bed611e1d053a4202eb3b1d7ad08aa91
|
|
| MD5 |
a856ea5b990e743e6ebbd3b073fa9a11
|
|
| BLAKE2b-256 |
c02fac0dbcf092aa283aa08f065a7c2f3b876768fa6b9006489f1725f762ab75
|
Provenance
The following attestation bundles were made for opentelemetry_instrumentation_genai_anthropic-1.0b0.tar.gz:
Publisher:
release-all.yml on open-telemetry/opentelemetry-python-genai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opentelemetry_instrumentation_genai_anthropic-1.0b0.tar.gz -
Subject digest:
7849e0615e6b7424f683b90bfef90765bed611e1d053a4202eb3b1d7ad08aa91 - Sigstore transparency entry: 2132313860
- Sigstore integration time:
-
Permalink:
open-telemetry/opentelemetry-python-genai@1e4aca50a0c5b5fcf8b3e2a7a81eec6ac12a1669 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-telemetry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-all.yml@1e4aca50a0c5b5fcf8b3e2a7a81eec6ac12a1669 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file opentelemetry_instrumentation_genai_anthropic-1.0b0-py3-none-any.whl.
File metadata
- Download URL: opentelemetry_instrumentation_genai_anthropic-1.0b0-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e5bd44df5a502f54222aee07502d8cf888ef5ad797500865acaad891d0c036a
|
|
| MD5 |
7bcbe632fdb4f53009d8c7004dae0332
|
|
| BLAKE2b-256 |
e9645f6d243ce0788ab76be59b6963c01a5341704807fde07210315333e5a7d1
|
Provenance
The following attestation bundles were made for opentelemetry_instrumentation_genai_anthropic-1.0b0-py3-none-any.whl:
Publisher:
release-all.yml on open-telemetry/opentelemetry-python-genai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opentelemetry_instrumentation_genai_anthropic-1.0b0-py3-none-any.whl -
Subject digest:
5e5bd44df5a502f54222aee07502d8cf888ef5ad797500865acaad891d0c036a - Sigstore transparency entry: 2132313999
- Sigstore integration time:
-
Permalink:
open-telemetry/opentelemetry-python-genai@1e4aca50a0c5b5fcf8b3e2a7a81eec6ac12a1669 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-telemetry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-all.yml@1e4aca50a0c5b5fcf8b3e2a7a81eec6ac12a1669 -
Trigger Event:
workflow_dispatch
-
Statement type: