examples/integration-opentelemetry/built-in/README.md
You can run this example with:
npx promptfoo@latest init --example integration-opentelemetry/built-in
cd integration-opentelemetry/built-in
This example demonstrates promptfoo's built-in OpenTelemetry tracing for LLM provider calls.
# Required for the providers you want to test
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
# Add other provider keys as needed
npx promptfoo eval -c promptfooconfig.yaml
npx promptfoo view
Navigate to the Traces tab to see detailed span information.
Tracing is enabled by default. Configure via environment variables:
| Variable | Default | Description |
|---|---|---|
PROMPTFOO_DISABLE_TRACING | false | Set to true to disable tracing |
OTEL_EXPORTER_OTLP_ENDPOINT | - | Export traces to external OTLP backend |
OTEL_SERVICE_NAME | promptfoo | Service name in traces |
docker run -d --name jaeger \
-e COLLECTOR_OTLP_ENABLED=true \
-p 16686:16686 \
-p 4318:4318 \
jaegertracing/all-in-one:latest
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 npx promptfoo eval
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io \
OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=YOUR_API_KEY" \
npx promptfoo eval
Each LLM call span includes:
gen_ai.system - Provider system (openai, anthropic, etc.)gen_ai.operation.name - Operation type (chat, completion, embedding)gen_ai.request.model - Requested model namegen_ai.request.max_tokens - Max tokens settinggen_ai.request.temperature - Temperature settinggen_ai.usage.input_tokens - Prompt tokens usedgen_ai.usage.output_tokens - Completion tokens usedgen_ai.usage.total_tokens - Total tokensgen_ai.usage.cached_tokens - Cached tokens (Anthropic)gen_ai.usage.reasoning_tokens - Reasoning tokens (o1 models)gen_ai.response.model - Actual model usedgen_ai.response.id - Provider response IDgen_ai.response.finish_reasons - Finish reasonspromptfoo.provider.id - Provider identifierpromptfoo.eval.id - Evaluation run IDpromptfoo.test.index - Test case indexpromptfoo.prompt.label - Prompt labelAll major providers are instrumented:
| Provider | Tracing Support |
|---|---|
| OpenAI | ✓ |
| Anthropic | ✓ |
| Azure OpenAI | ✓ |
| AWS Bedrock | ✓ |
| Google Vertex AI | ✓ |
| Ollama | ✓ |
| Mistral | ✓ |
| Cohere | ✓ |
| Huggingface | ✓ |
| IBM Watsonx | ✓ |
| HTTP | ✓ |
| OpenRouter | ✓ |
| Replicate | ✓ |
| OpenAI-compatible | ✓ (inherited) |
| Cloudflare AI | ✓ (inherited) |