Skip to main content

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.

Metadata

Release files for opentelemetry-instrument-anthropic 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opentelemetry-instrument-anthropic 0.0.2
File Size Uploaded
opentelemetry_instrument_anthropic-0.0.2.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-instrument-anthropic 0.0.2
File Interpreter ABI Platform
opentelemetry_instrument_anthropic-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / opentelemetry_instrument_anthropic-0.0.2.tar.gz

Download URL opentelemetry_instrument_anthropic-0.0.2.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
43df3c90c9f900890e91204de168a16ce371818f656e741e5215ce78449aa3e2
BLAKE2b-256 checksum
How to use checksums
b4556362d6f819e7c1212a3e093862f721afaa36b6567bb460af5fb2c2029c5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.18 Linux/5.15.0-1041-azure

Release files / opentelemetry_instrument_anthropic-0.0.2-py3-none-any.whl

Download URL opentelemetry_instrument_anthropic-0.0.2-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9be125f51501de77c20d83b2a6e17acf59dae91724a871f3116b171471cb3920
BLAKE2b-256 checksum
How to use checksums
57eae588bc760161d6bbf5d106b41dbec1e5164305bfa2f2ebbd7e487c5b30d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.18 Linux/5.15.0-1041-azure

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page