Skip to main content

Respan instrumentation plugin for the Anthropic SDK

Project description

respan-instrumentation-anthropic

Respan instrumentation plugin for the Anthropic Python SDK.

This package patches Anthropic client calls and emits spans using the Respan/Traceloop GenAI attribute shape used across this repository.

Install

pip install respan-instrumentation-anthropic

Quickstart

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()],
)

client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

message = client.messages.create(
    model="claude-3-5-haiku-latest",
    max_tokens=128,
    messages=[{"role": "user", "content": "Write one line about tracing."}],
)

print(message.content)
respan.flush()

Notes

  • The instrumentor patches both Anthropic and AsyncAnthropic.
  • messages.create() and streaming responses are traced.
  • Managed agent session streaming is also captured when available through the Anthropic SDK.

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

respan_instrumentation_anthropic-1.0.2.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file respan_instrumentation_anthropic-1.0.2.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_anthropic-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3e088e07651371914a25082bb0333d55a713c0ddcdac1d19ab43c9a35fb99fd9
MD5 13c2968ddda1c27d4d8d83f8748de72f
BLAKE2b-256 4bfe3210e84e5c35eb03915661b3929d70f25fcf832a97a6a63e9d0451d15df4

See more details on using hashes here.

Provenance

The following attestation bundles were made for respan_instrumentation_anthropic-1.0.2.tar.gz:

Publisher: publish.yml on respanai/respan

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

File details

Details for the file respan_instrumentation_anthropic-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_anthropic-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e9e776b4dcb6542d01d5de05e35a94d7b6fb511385b3161d496b82b38bf3c274
MD5 bd7d8fced1d9e98f4140cdf3268faf8a
BLAKE2b-256 9f943477b8c52139e53e185b07e463f7d8bd13ca70099755c1bb8ea85628b99c

See more details on using hashes here.

Provenance

The following attestation bundles were made for respan_instrumentation_anthropic-1.0.2-py3-none-any.whl:

Publisher: publish.yml on respanai/respan

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