Skip to main content

OpenTelemetry Anthropic instrumentation

Project description

pypi

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


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

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file opentelemetry_instrumentation_genai_anthropic-1.0b0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_genai_anthropic-1.0b0.tar.gz
Algorithm Hash digest
SHA256 7849e0615e6b7424f683b90bfef90765bed611e1d053a4202eb3b1d7ad08aa91
MD5 a856ea5b990e743e6ebbd3b073fa9a11
BLAKE2b-256 c02fac0dbcf092aa283aa08f065a7c2f3b876768fa6b9006489f1725f762ab75

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opentelemetry_instrumentation_genai_anthropic-1.0b0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_genai_anthropic-1.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e5bd44df5a502f54222aee07502d8cf888ef5ad797500865acaad891d0c036a
MD5 7bcbe632fdb4f53009d8c7004dae0332
BLAKE2b-256 e9645f6d243ce0788ab76be59b6963c01a5341704807fde07210315333e5a7d1

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page