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.0.tar.gz (7.2 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.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_anthropic-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a18c0fbe4cda3d517cdb99049134ecd4c20d68d79017e1194c53fc9673c5dfd8
MD5 503bd462c45fb12ec10f59cd443924ae
BLAKE2b-256 c29a9afccc4fb7bc840ec7c2a41aaac14031792465b7285ddfb0833feaa3e3c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for respan_instrumentation_anthropic-1.0.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_anthropic-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15738c9d7854334b90781527f260d42672ce2123e4925852714c561a9b7c5cac
MD5 ae0454e02436e1e8a062cee95609cc00
BLAKE2b-256 48d82089ee92302f30321503461ed034324f0bb70effd494b4a9de9a08ac65d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for respan_instrumentation_anthropic-1.0.0-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