Splyntra
PostShare
Back to all guides
opentelemetrygenaisemantic-conventionsstandardstracingotlp

OpenTelemetry GenAI Semantic Conventions: The Definitive Reference Guide

An in-depth technical reference to the OpenTelemetry GenAI Semantic Conventions for AI agents and LLMs. Learn the official attributes, span hierarchies, metrics, and OTLP payload specifications.

AR
Alex Rivera
Head of Infrastructure & Observability
13 min read

As generative AI and autonomous agent applications move from experimental scripts into enterprise production, the need for standardized, vendor-neutral telemetry has never been more urgent. Proprietary SDKs create lock-in, make multi-model architectures fragile, and isolate AI logs from backend infrastructure telemetry.

To solve this, the OpenTelemetry Generative AI Semantic Conventions Working Group established the official standard for modeling LLM calls, embeddings, vector searches, and autonomous agent workflows.

This guide provides the complete technical reference for the OpenTelemetry GenAI Semantic Conventions, detailing attributes, span types, event structures, and OTLP payload formats.


1. Core Namespace Structure

OpenTelemetry organizes GenAI attributes under the gen_ai.* namespace hierarchy:

gen_ai.*
├── gen_ai.system                (Framework / Provider: "splyntra", "openai", "anthropic")
├── gen_ai.request.*             (Requested parameters: model, temperature, max_tokens)
├── gen_ai.response.*            (Returned metadata: model, finish_reasons, id)
├── gen_ai.usage.*               (Token counters: prompt_tokens, completion_tokens)
├── gen_ai.agent.*               (Agent primitives: name, step, goal, task_id)
└── gen_ai.tool.*                (Tool execution: name, call_id, parameters, status)

2. The Comprehensive GenAI Attribute Reference

AttributeTypeDescriptionConformanceExample
gen_ai.systemstringThe system or provider fulfilling the operation.Required"openai", "anthropic", "splyntra"
gen_ai.request.modelstringThe target model identifier specified in the request.Required"gpt-4o", "claude-3-7-sonnet"
gen_ai.response.modelstringThe exact model snapshot returned in the response.Recommended"gpt-4o-2024-08-06"
gen_ai.request.temperaturedoubleSampling temperature requested.Optional0.7
gen_ai.request.top_pdoubleNucleus sampling probability.Optional0.95
gen_ai.request.max_tokensintMaximum output tokens configured.Optional4096
gen_ai.response.finish_reasonsstring[]Reasons why generation terminated.Recommended["stop"], ["tool_calls"]
gen_ai.response.idstringUnique completion ID assigned by provider.Optional"chatcmpl-9xAbc..."
gen_ai.usage.prompt_tokensintInput token count.Required2450
gen_ai.usage.completion_tokensintGenerated output token count.Required412
gen_ai.usage.cached_tokensintInput tokens served from prefix cache.Recommended1800
gen_ai.agent.namestringCanonical name of the executing agent role.Required (Agent)"triage_agent"
gen_ai.agent.step_numberintCurrent iteration in the agent loop.Recommended3
gen_ai.tool.namestringName of the function/tool called.Required (Tool)"query_sql"
gen_ai.tool.call_idstringUnique invocation ID matching LLM tool call.Required (Tool)"call_981a"

3. Span Hierarchy & Operation Names

OpenTelemetry specifies consistent operation names for Generative AI spans:

Span: agent.workflow (Kind: SERVER / INTERNAL)
│
├── Span: gen_ai.chat (Kind: CLIENT)
│   ├── Attribute: gen_ai.system = "openai"
│   ├── Attribute: gen_ai.request.model = "gpt-4o"
│   └── Event: gen_ai.content.prompt (optional if sanitized)
│
├── Span: gen_ai.tool (Kind: INTERNAL)
│   ├── Attribute: gen_ai.tool.name = "fetch_weather"
│   └── Attribute: gen_ai.tool.parameters = "{\"city\": \"Tokyo\"}"
│
└── Span: gen_ai.embeddings (Kind: CLIENT)
    ├── Attribute: gen_ai.system = "openai"
    └── Attribute: gen_ai.request.model = "text-embedding-3-small"

4. Constructing Raw OTLP Payloads in JSON

When sending telemetry over HTTP to https://ingest.splyntra.com/v1/traces, spans are formatted using the standard protobuf/JSON OTLP schema:

{
  "resourceSpans": [
    {
      "resource": {
        "attributes": [
          { "key": "service.name", "value": { "stringValue": "customer-support-agent" } },
          { "key": "deployment.environment", "value": { "stringValue": "production" } }
        ]
      },
      "scopeSpans": [
        {
          "scope": { "name": "splyntra.genai.tracer", "version": "1.0.0" },
          "spans": [
            {
              "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
              "spanId": "00f067aa0ba902b7",
              "name": "gen_ai.chat",
              "kind": 3,
              "startTimeUnixNano": 1723632000000000000,
              "endTimeUnixNano": 1723632000650000000,
              "attributes": [
                { "key": "gen_ai.system", "value": { "stringValue": "openai" } },
                { "key": "gen_ai.request.model", "value": { "stringValue": "gpt-4o" } },
                { "key": "gen_ai.usage.prompt_tokens", "value": { "intValue": 1820 } },
                { "key": "gen_ai.usage.completion_tokens", "value": { "intValue": 290 } },
                { "key": "splyntra.cost_usd", "value": { "doubleValue": 0.00745 } },
                { "key": "splyntra.risk_score", "value": { "doubleValue": 0.02 } }
              ],
              "status": { "code": 1 }
            }
          ]
        }
      ]
    }
  ]
}

5. Standardized GenAI Metrics

In addition to distributed traces, the OpenTelemetry working group specifies standard Prometheus/OTel metric instruments:

  • gen_ai.client.token.usage (Histogram): Measures prompt and completion token counts per request.
  • gen_ai.client.operation.duration (Histogram): Measures end-to-end latency of LLM and tool calls.
  • gen_ai.client.time_to_first_token (Histogram): Measures TTFT for streaming completions.
  • gen_ai.agent.step_count (Histogram): Measures iteration distribution across agent runs.

AR
Alex Rivera
Head of Infrastructure & Observability

Building the unified OpenTelemetry observability, risk scoring, and FinOps control plane for autonomous AI agents.

Related Technical Guides

Explore more deep dives on OpenTelemetry, agent security, and FinOps.

See your agents clearly with Splyntra

Trace, evaluate, secure, and govern your AI agents on one OpenTelemetry pipeline — every run, with a risk score.

Back to all posts