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.1.tar.gz (11.1 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.1.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_anthropic-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b54ab9c98bc70b752db176cf033dd0d0d19cc251ae6a1e995e34c78ae4cf0ce6
MD5 0ef590ec6eb2cd5e49fc5f0f423d6be9
BLAKE2b-256 257cf55d77b852715e6c27ff60111a7a9ff88b3af6318bfd4be080b0810a347b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for respan_instrumentation_anthropic-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0a19d03250d20a7f8de82eeab143b1e052604aa8feea94da94558a5ecc3390c
MD5 a50c745e90298b6b6e7bc7b4c48d45f0
BLAKE2b-256 09110b5302906a9ce5e3d3fd7bd94ce7a50496bcfc8ba9e6c46a17bd2ece55a9

See more details on using hashes here.

Provenance

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