OpenTelemetry (OTEL) Support

AI Gateway is OpenTelemetry (OTEL) compliant, making it easy to integrate with modern observability tools and platforms. Both Tracing and Metrics are supported for deep observability and monitoring.

Tracing

OpenTelemetry tracing allows you to capture detailed traces of requests as they flow through the AI Gateway. This enables debugging, performance analysis, and end-to-end visibility.

How to Enable Tracing

Set the following environment variables:
  • ENABLE_OTEL_TRACING: Set to "true" to enable OTEL tracing.
  • OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: The OTEL traces exporter endpoint (e.g., your collector or backend).
  • OTEL_EXPORTER_OTLP_TRACES_HEADERS: Any required headers for authentication/configuration.
  • OTEL_SERVICE_NAME: The name of your service as recognized by OTEL.

Example for TrueFoundry Tracing Project

ENABLE_OTEL_TRACING="true"
OTEL_SERVICE_NAME=<custom_service_name>
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://<tfy-control-plane-base-url>/api/otel/v1/traces"
OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=Bearer <TOKEN>,TFY-Tracing-Project=tracing-project:truefoundry/<PROJECT_NAME>/<custom_service_name>"

Example Trace Overview

AI Gateway - OpenTelemetry Tracing

Each row on the left represents a request to the endpoint, with the selected trace showing a detailed breakdown of the request and its spans. Highlighted Span – chatCompletions (LLM):
The highlighted span is of type genai (LLM), capturing the lifecycle of a large language model (LLM) inference request.
LLM Request Data:
  • Model: openai-main/gpt-4o
  • Max tokens: 200
  • Top-p: 1
  • Temperature: 0.1
Prompt and Completion:
The system prompt, user question, and assistant’s response are all visible, providing full transparency into the LLM interaction.
Span Metadata:
Includes span name, service name, trace and span IDs, and OTEL scope.

AI Gateway Spans

The following sections describe the various spans available in the AI Gateway and their attributes.