OpenTelemetry instrumentation for Anthropic
Project description
Anthropic OpenTelemetry Integration
Overview
This integration provides support for using OpenTelemetry with the Anthropic framework. It enables tracing and monitoring of applications built with Anthropic.
Installation
- Install traceAI Anthropic
pip install traceAI-anthropic
Set Environment Variables
Set up your environment variables to authenticate with FutureAGI
import os
os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY
os.environ["ANTHROPIC_API_KEY"] = ANTHROPIC_API_KEY
Quickstart
Register Tracer Provider
Set up the trace provider to establish the observability pipeline. The trace provider:
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="anthropic_app"
)
Configure Anthropic Instrumentation
Instrument the Anthropic client to enable telemetry collection. This step ensures that all interactions with the Anthropic SDK are tracked and monitored.
from traceai_anthropic import AnthropicInstrumentor
AnthropicInstrumentor().instrument(tracer_provider=trace_provider)
Create Anthropic Components
Set up your Anthropic client with built-in observability.
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-3-5-sonnet-20240620",
max_tokens=1024,
tools=[
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The unit of temperature, either 'celsius' or 'fahrenheit'",
},
},
"required": ["location"],
},
},
{
"name": "get_time",
"description": "Get the current time in a given time zone",
"input_schema": {
"type": "object",
"properties": {
"timezone": {
"type": "string",
"description": "The IANA time zone name, e.g. America/Los_Angeles",
}
},
"required": ["timezone"],
},
},
],
messages=[
{
"role": "user",
"content": "What is the weather like right now in New York?"
" Also what time is it there? Use necessary tools simultaneously.",
}
],
)
print(response)
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 traceai_anthropic-0.1.7.tar.gz
.
File metadata
- Download URL: traceai_anthropic-0.1.7.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0967159c01fa7996312229a8a556ad7540d4474f1f88138aaea6dadeedf2144e
|
|
MD5 |
422ba981f7a933853f445a3cf5fc24be
|
|
BLAKE2b-256 |
c27f950eaab3181c0bf86d7a2c09d1e64f348ffc76658dcf1d926bf89334b90e
|
File details
Details for the file traceai_anthropic-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: traceai_anthropic-0.1.7-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
209b6aea95a997c863a6902466f36dd372465fcec899ebee4b58794051d4fc97
|
|
MD5 |
76890eadb48443068b4ef5285d220205
|
|
BLAKE2b-256 |
8a9d60094311ef4ae1adc1dd7c4682fc632fac9ecce5d2d4f670e2beb4b88ffc
|