← All notes

Record GenAI work as OpenTelemetry traces and client spans

Answer: Traces give the path of a request through your application. Spans in that request share the same trace_id. GenAI conventions treat a client span as a logical operation observed by the caller, covering that operation from start to finish, including automatic retries.

Traces and spans

Traces give the big picture of what happens when a request is made to an application. A trace is the path of a request through your application. One way to think of traces is that they are structured logs plus context, correlation, and hierarchy. Spans in the same request share a trace_id. The root span has no parent_id. A Tracer Provider is a factory for Tracers, typically initialized once, including Resource and Exporter initialization. Trace Exporters send traces to a consumer.

GenAI client spans

GenAI spans represent logical operations as observed by the caller. The span should cover the duration of the operation. It starts when work is initiated and ends when the response is fully received, or when the operation is terminated due to an error or cancellation. If a request was retried automatically, the span should include every retry of that logical operation. The conventions also describe inference, embeddings, retrievals, memory, and execute tool spans. For Fetch response, the name SHOULD be fetch_response and Span kind SHOULD be CLIENT. Status is Development.

| trace_id | parent_id | |---|---| | trace_id | field indicating the trace | | parent_id | missing on the root span | | Tracer Provider | factory for Tracers | | Trace Exporters | send traces to a consumer |

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: OpenTelemetry, Traces; open-telemetry/semantic-conventions-genai (GitHub), Semantic conventions for generative client AI spans. CC-BY-4.0; Apache-2.0. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: OpenTelemetry, Traces; open-telemetry/semantic-conventions-genai (GitHub), Semantic conventions for generative client AI spans. CC-BY-4.0; Apache-2.0.

Cite this

Permanent ID: iil:note:v0ttmbeb

iinventedlight. 2026. "Record GenAI work as OpenTelemetry traces and client spans." iinventedlight Library, iil:note:v0ttmbeb, version of 2026-11-19. https://iinventedlight.com/library/notes/otel-genai-spans/. License: CC-BY-4.0.

@misc{iil_note_v0ttmbeb,
  author = {{iinventedlight}},
  title = {{Record GenAI work as OpenTelemetry traces and client spans}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-19},
  url = {https://iinventedlight.com/library/notes/otel-genai-spans/},
  note = {Permanent ID iil:note:v0ttmbeb. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/otel-genai-spans.md.