OpenTelemetry for LLM observability standardizes traces, metrics, and logs across AI applications. Learn how Bifrost uses OTLP and GenAI semantic conventions to monitor AI workloads.
An OpenTelemetry standard for LLM observability provides a vendor-neutral schema to capture traces, metrics, and logs across distributed AI workloads. Traditional Application Performance Monitoring (APM) tools were designed for deterministic HTTP endpoints and database queries, but Large Language Models (LLMs) introduce new variables: non-deterministic output generation, streaming token rates, variable prompt costs, multi-turn conversations, and complex agentic tool calls. As AI architectures evolve into multi-provider pipelines and complex agentic workflows, routing model requests through Bifrost, an open-source AI gateway from Maxim AI, enables engineering teams to export OpenTelemetry Protocol (OTLP) telemetry without altering application code.
What is OpenTelemetry for LLM Observability?
OpenTelemetry for LLM observability extends the Cloud Native Computing Foundation (CNCF) open standard to Large Language Model applications. It defines standardized attributes for tracking model invocations, prompt and output tokens, request latency, model providers, agent reasoning loops, and tool executions across heterogeneous observability backends using the OpenTelemetry Protocol (OTLP).
In traditional software systems, tracing a request involves monitoring HTTP status codes and database query execution times. Generative AI applications require a richer telemetry model that spans three core signals:
- Traces: Distributed spans that map the end-to-end execution path of a request. A single user query might generate spans for prompt retrieval, vector database query execution, guardrail checks, LLM invocation, and downstream tool calls.
- Metrics: Aggregated quantitative data points that track operational health. Key metrics include input and output token consumption, time-to-first-token (TTFT), token generation rates (tokens per second), model invocation duration histograms, error rates, and cache hit ratios.
- Logs: Structured event records containing contextual request details, such as system prompts, user inputs, model completions, tool arguments, and safety evaluation results.
By standardizing these three signals under the OpenTelemetry specification, engineering teams avoid vendor lock-in. Telemetry emitted by an application or gateway can be ingested simultaneously by platforms like Grafana, Datadog, Jaeger, or specialized platforms like Maxim AI observability.
OpenTelemetry GenAI Semantic Conventions Explained
To ensure that telemetry emitted by different libraries, frameworks, and gateways remains consistent, the OpenTelemetry community established a dedicated working group under the open-telemetry/semantic-conventions-genai repository. These semantic conventions define standardized key names and value types for GenAI attributes.
Rather than having one tool export prompt_tokens and another export input_token_count, the OpenTelemetry GenAI semantic conventions establish a shared vocabulary across the industry.
| Attribute Name | Data Type | Description | Example Value |
|---|---|---|---|
gen_ai.operation.name |
String | Type of operation performed |
chat, text_completion, embeddings
|
gen_ai.provider.name |
String | Target model provider or host |
openai, anthropic, bedrock, azure
|
gen_ai.request.model |
String | Model requested by the client application |
gpt-4o, claude-3-5-sonnet
|
gen_ai.response.model |
String | Specific model version returned by provider | gpt-4o-2024-08-06 |
gen_ai.usage.input_tokens |
Integer | Count of tokens in the prompt context | 1248 |
gen_ai.usage.output_tokens |
Integer | Count of tokens generated in the response | 312 |
gen_ai.client.operation.duration |
Double | Total time elapsed for the model invocation (seconds) | 1.42 |
Beyond basic model invocations, these semantic conventions extend to agentic workflows and tool execution. When an AI agent invokes external tools using the Model Context Protocol, OpenTelemetry spans record the tool name, input arguments, execution status, and return payloads. Operating Bifrost as an MCP gateway allows infrastructure engineers to capture tool execution telemetry automatically at the gateway level.
Architectural Approaches: Gateway Telemetry vs. SDK Instrumentation
Engineering teams implementing OpenTelemetry for LLM observability generally choose between two architectural patterns: SDK-level auto-instrumentation and central gateway-level export.
SDK-Level Instrumentation
SDK-level instrumentation relies on language-specific libraries (such as Python or TypeScript packages) installed directly inside application microservices. These libraries wrap model provider clients (like the OpenAI SDK or Anthropic SDK) and automatically generate OpenTelemetry spans whenever an API call is initiated.
- Advantages: Captures internal application context, such as local variable states or function call stacks within the application runtime.
- Drawbacks: Requires adding dependencies to every microservice, maintaining library updates across multiple languages, and managing runtime memory overhead inside the application code.
Gateway-Level Telemetry
Gateway-level telemetry shifts observability out of application code and into the infrastructure boundary. By routing model traffic through a centralized gateway, all prompt requests and model responses are intercepted, formatted into standard OTLP spans, and exported directly to collector endpoints.
Bifrost uses this gateway pattern to deliver zero-code-change telemetry. In sustained production benchmarks, Bifrost processes requests with only 11 microseconds of overhead per request at 5,000 requests per second. Applications simply update their API base URL through a drop-in replacement configuration, gaining automatic OpenTelemetry tracing without installing specialized language SDKs.
Implementing OpenTelemetry Tracing with Bifrost
Bifrost includes built-in observability alongside an official OpenTelemetry plugin. The gateway constructs native OTLP traces conforming to the OpenTelemetry GenAI semantic conventions (genai_extension) and streams them over HTTP or gRPC to any standard OTel Collector.
Configuration Example
Below is a declarative configuration snippet showing how to enable OpenTelemetry export in Bifrost:
bifrost:
plugins:
otel:
enabled: true
config:
service_name: "ai-gateway-production"
traces_enabled: true
collector_url: "http://otel-collector.monitoring.svc.cluster.local:4318/v1/traces"
trace_type: "genai_extension"
protocol: "http"
headers:
Authorization: "Bearer env.OTEL_EXPORTER_TOKEN"
When this configuration is active, every request routed through Bifrost generates structured spans containing prompt metadata, completion details, token breakdowns, and provider response latencies.
Multi-Backend Telemetry Architecture
Because Bifrost supports standard OpenTelemetry protocols, traces can be directed to multiple enterprise backends simultaneously:
- APM and Distributed Tracing: Route traces to Grafana Tempo, Jaeger, or Datadog using the Datadog connector to correlate LLM calls with upstream microservices and downstream databases.
- Infrastructure Metrics: Combine trace data with scrapable Prometheus metrics to monitor overall gateway throughput, connection pools, and semantic caching hit rates.
- Dedicated AI Observability: Stream traces directly to Maxim AI observability for advanced trace analysis, prompt quality evaluation, and automated regression testing.
Beyond gateway-level observability, Bifrost applies centralized governance and security controls using virtual keys and audit logs, while Bifrost Edge extends those controls to local machine traffic with endpoint security and app governance.
Best Practices for OpenTelemetry in Production AI Systems
Deploying OpenTelemetry for LLM observability in production systems requires balancing visibility with data privacy, storage costs, and network efficiency.
1. Configure Opt-In Content Capture and Redaction
Prompts and completions often contain sensitive business logic, Personally Identifiable Information (PII), or confidential enterprise data. The OpenTelemetry specification treats message payload capture (gen_ai.input.messages and gen_ai.output.messages) as opt-in behavior. Platform engineers should enforce strict PII redaction and secret masking before telemetry leaves the network perimeter.
2. Implement Distributed Context Propagation
To trace a request from a user's web browser through backend microservices down to an LLM provider call, applications must propagate context headers using the W3C Trace Context standard (traceparent and tracestate). When an incoming HTTP request includes a traceparent header, Bifrost attaches its model invocation spans to the existing trace, preserving full context across microservice boundaries.
3. Track Token Usage and Cost Allocation
Token counts directly drive infrastructure expenses. Ensure that all generated OTLP spans contain accurate gen_ai.usage.input_tokens and gen_ai.usage.output_tokens attributes. By attaching consumer metadata (such as Virtual Key IDs or team identifiers) to trace attributes, platform teams can generate real-time cost attribution reports across departments.
4. Sample Telemetry at Scale
High-volume production environments generating millions of model calls per day can incur substantial observability storage costs. Implement probabilistic or tail-based sampling in an OpenTelemetry Collector layer. For example, retain 100% of error traces and high-latency outlier requests while sampling 5% of routine, successful completions.
Evaluating OpenTelemetry for Your AI Infrastructure
Adopting OpenTelemetry for LLM observability provides engineering teams with vendor-neutral visibility, standardized token accounting, and unified tracing across distributed microservices and model providers. Capturing this telemetry at the gateway layer eliminates the need to maintain language-specific instrumentation SDKs across multiple application repositories.
Engineering teams evaluating open-source LLM gateways and OpenTelemetry export pipelines can review the Bifrost documentation, explore the open-source repository, or request a Bifrost demo to configure production AI governance.
















