Skip to main content

Instruments Anthropic client for OpenTelemetry

Project description

opentelemetry-instrument-anthropic-py

Autoinstrumentation for Anthropic's client library.

Project site: https://github.com/fxchen/opentelemetry-instrument-anthropic-py

Usage

Installaion

poetry add opentelemetry-instrument-anthropic
poetry run opentelemetry-bootstrap -a install
poetry run opentelemetry-instrument python your_app.py

Using auto instrumentation agent

poetry add opentelemetry-instrument-anthropic
poetry run opentelemetry-bootstrap -a install
poetry run opentelemetry-instrument python your_app.py

Manually

from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
from opentelemetry.instrumentation.anthropic import AnthropicInstrumentor

AnthropicInstrumentor().instrument()

client = Anthropic()
client.completions.create(
    prompt=f"{HUMAN_PROMPT}\nHello world\n{AI_PROMPT}",
    )

🔗 Example chat.py

In this folder there's a readme on how to:

  • Execute a chat completion against Anthropic
  • Send traces to your console or your OLTP provider!

Acknowledgments

Thank you very much to Phillip Carter and instrumentation by the OpenTelemetry Community! This instrumentation was heavily inspired by conversation and this OpenAI library.

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

File details

Details for the file opentelemetry_instrument_anthropic-0.0.2.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_instrument_anthropic-0.0.2.tar.gz
Algorithm Hash digest
SHA256 43df3c90c9f900890e91204de168a16ce371818f656e741e5215ce78449aa3e2
MD5 0cc4865969ebe873b98cb4fd88f15a56
BLAKE2b-256 b4556362d6f819e7c1212a3e093862f721afaa36b6567bb460af5fb2c2029c5d

See more details on using hashes here.

File details

Details for the file opentelemetry_instrument_anthropic-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrument_anthropic-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9be125f51501de77c20d83b2a6e17acf59dae91724a871f3116b171471cb3920
MD5 ecb7fb2bdce36bd5bbb6a186e5a6b753
BLAKE2b-256 57eae588bc760161d6bbf5d106b41dbec1e5164305bfa2f2ebbd7e487c5b30d0

See more details on using hashes here.

Supported by

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