Setup Tracing
The Agenta Observability SDK integrates with the OpenTelemetry SDK. It wraps OpenTelemetry and provides a user-friendly way to instrument your LLM applications.
The SDK provides:
- Automatic OpenTelemetry setup
- Easy function instrumentation using decorators
- Reference prompt versions to link traces to applications, variants, and environments
- Add attributes to spans for additional metadata
The SDK works with auto instrumentation. You should use auto instrumentation together with this SDK.
Installation
1. Install the Agenta SDK
pip install -U agenta
Configuration
2. Set environment variables
- Visit the Agenta API Keys page.
- Click on Create New API Key and follow the prompts.
import os
os.environ["AGENTA_API_KEY"] = "YOUR_AGENTA_API_KEY"
os.environ["AGENTA_HOST"] = "https://cloud.agenta.ai"
3. Initialize the SDK
import agenta as ag
ag.init()
That's it! You're now ready to instrument your functions and start capturing traces.
Next steps
- Learn how to instrument your functions
- Link traces to prompt versions
- Understand how to redact sensitive data
