Gen AI OpenTelemetry spans attributes reference

This feature is currently in Tech Preview and should not be used in a production environment.

AI Gateway supports OpenTelemetry instrumentation for generative AI traffic. When an OpenTelemetry (OTEL) Policy is enabled in AI Gateway, a set of Gen AI-specific attributes are emitted on tracing spans. These attributes provide insight into the Gen AI request lifecycle (inputs, model, and outputs), usage, and tool or agent interactions.

You can also capture Agent2Agent traffic (A2A) by enabling statistics logging on AI Agents.

You can export these attributes via a supported backend to:

  • Inspect which AI Model or AI Model Provider handled a request
  • Track A2A conversation and task identifiers across requests
  • Analyze prompt structure (system vs. user vs. tool messages)
  • Evaluate model parameters (such as temperature and max tokens)
  • Measure tool-call behavior (which tools were invoked, and their metadata)
  • Monitor token usage (input vs. output) for cost or performance analysis

The span data is sent to the configured OTEL endpoint through the Kong tracing. Use a Policy configured with OpenTelemetry or Zipkin to export these spans to backends such as Jaeger.

This page covers span attributes (per-request tracing data). AI Gateway also supports OTLP metrics (aggregated counters and histograms for latency, token usage, cost, and error rates). See the Gen AI OpenTelemetry metrics reference for details.

Some Gen AI span attributes can include sensitive request or response payload data. In particular, gen_ai.input.messages and gen_ai.output.messages may contain prompts, model outputs, PII, secrets, or credentials. Review your tracing, retention, access-control, and redaction requirements before enabling or exporting payload-related tracing data.

Span attribute reference

Gen AI span attributes

Gen AI tracing span emitted for LLM requests.

The following span attributes use the kong.gen_ai prefix:

Attribute

Attribute description

gen_ai.operation.name Operation requested, such as chat or embeddings.
gen_ai.provider.name Name of the Gen AI provider.
gen_ai.request.model Model name targeted by the request.
gen_ai.request.max_tokens Maximum token limit configured for the request.
gen_ai.request.temperature Sampling temperature configured for the request.
gen_ai.input.messages Array of input messages sent to the model.
gen_ai.output.type Output payload type, such as json.
gen_ai.output.messages Array containing the full model response payload.
gen_ai.response.id Unique identifier returned by the provider for the response.
gen_ai.response.model Model name reported by the provider in the response.
gen_ai.response.finish_reasons Array of finish reasons returned by the provider.
gen_ai.usage.input_tokens Number of input tokens consumed by the request.
gen_ai.usage.output_tokens Number of output tokens generated in the response.

Gen AI tool call span attributes

Gen AI tracing span emitted when the provider response includes a tool call.

The following span attributes use the kong.gen_ai prefix:

Attribute

Attribute description

gen_ai.operation.name Operation requested, such as chat or embeddings.
gen_ai.provider.name Name of the Gen AI provider.
gen_ai.request.model Model name targeted by the request.
gen_ai.request.max_tokens Maximum token limit configured for the request.
gen_ai.request.temperature Sampling temperature configured for the request.
gen_ai.response.finish_reasons Array of finish reasons returned by the provider.
gen_ai.response.id Unique identifier returned by the provider for the response.
gen_ai.response.model Model name reported by the provider in the response.
gen_ai.tool.call.id Unique identifier for the specific tool call.
gen_ai.tool.name Name of the tool or function requested by the model.
gen_ai.tool.type Tool type, such as function.
gen_ai.usage.input_tokens Number of input tokens consumed by the request.
gen_ai.usage.output_tokens Number of output tokens generated in the response.
gen_ai.output.type Output payload type, such as json.

A2A span attributes

A2A tracing span emitted for agent-to-agent requests.

The following span attributes use the kong.a2a prefix or the rpc prefix:

Attribute

Attribute description

kong.a2a.protocol.version A2A protocol version used for the request.
rpc.system RPC protocol used by the request, such as jsonrpc.
rpc.method RPC method invoked by the client.
kong.a2a.task.id Identifier of the A2A task.
kong.a2a.task.state Current state of the A2A task.
kong.a2a.context.id Identifier of the A2A conversation context.
kong.a2a.operation A2A operation name, such as message/send.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!