Expand description
OTel GenAI / MCP semantic-convention names shared by every OTel emission
surface (OtelHandler and OtelTracingBackend) so the two cannot drift.
Other crates (e.g. lc-agents) may also reference the pub constants
here instead of hardcoding attribute strings.
§Stability (T10, v0.23 — 2026 alignment)
The GenAI semconv is still published at Development stability: in 2026
the working group moved the docs to a dedicated repository
(open-telemetry/semantic-conventions-genai) and renames still happen
(notably gen_ai.usage.cache_creation.input_tokens →
GEN_AI_USAGE_CACHE_WRITE). Centralizing every name in this module is
deliberate: when the registry moves a name, one constant changes and both
export surfaces follow. The provider-extension and agent/tool attributes
below follow the 2026 draft (gen-ai-agent-spans.md, gen-ai-events.md,
mcp.md); the core chat attributes (provider.name, operation.name,
request/response model, usage, finish_reasons) follow the March 2025 stable
release.
MCP client spans live in lc-mcp, which cannot depend on this crate;
their mcp.* constants are mirrored in lc_mcp::instrument with a
cross-reference comment.
Constants§
- ERROR_
TYPE - Standard error attribute (OTel general semconv).
- EVENT_
INFERENCE_ DETAILS gen_ai.client.inference.operation.details(2026 events model, Opt-In).- GEN_
AI_ AGENT_ NAME gen_ai.agent.name— agent identity forinvoke_agent/planspans.- GEN_
AI_ CHOICE_ INDEX gen_ai.choice.index.- GEN_
AI_ INPUT_ MESSAGES - Structured input messages JSON on
EVENT_INFERENCE_DETAILS. - GEN_
AI_ MESSAGE_ CONTENT gen_ai.message.content— payload key of the legacy per-message span events (seeEVENT_INFERENCE_DETAILSdoc for why those are retained).- GEN_
AI_ OPERATION_ NAME gen_ai.operation.name(chat / execute_tool / invoke_agent / plan / retrieve …).- GEN_
AI_ OUTPUT_ MESSAGES - Structured output messages JSON on
EVENT_INFERENCE_DETAILS. - GEN_
AI_ PROVIDER_ NAME gen_ai.provider.name(stabilized rename of experimentalgen_ai.system).- GEN_
AI_ REQUEST_ MAX_ TOKENS gen_ai.request.max_tokens.- GEN_
AI_ REQUEST_ MODEL gen_ai.request.model.- GEN_
AI_ REQUEST_ TEMPERATURE gen_ai.request.temperature.- GEN_
AI_ RESPONSE_ FINISH_ REASONS gen_ai.response.finish_reasons(string array, plural).- GEN_
AI_ RESPONSE_ MODEL gen_ai.response.model.- GEN_
AI_ TOOL_ CALL_ ARGUMENTS gen_ai.tool.call.arguments— Opt-In: recorded only when explicitly enabled.- GEN_
AI_ TOOL_ CALL_ ID gen_ai.tool.call.id— the provider tool-call id (Recommended, 2026 draft).- GEN_
AI_ TOOL_ CALL_ RESULT gen_ai.tool.call.result— Opt-In: recorded only when explicitly enabled.- GEN_
AI_ TOOL_ DESCRIPTION gen_ai.tool.description(Recommended, 2026 draft).- GEN_
AI_ TOOL_ NAME gen_ai.tool.name(tool spans; conditionally required on MCP tool calls).- GEN_
AI_ USAGE_ CACHE_ READ gen_ai.usage.cache_read.input_tokens(Anthropic prompt-cache hits).- GEN_
AI_ USAGE_ CACHE_ WRITE gen_ai.usage.cache_write.input_tokens— the 2026-draft rename ofgen_ai.usage.cache_creation.input_tokens(still the published name in registry v1.40). Provider payloads use both spellings (cache_write_input_tokensand the Anthropic legacycache_creation_input_tokens); the handler accepts either key.- GEN_
AI_ USAGE_ INPUT_ TOKENS gen_ai.usage.input_tokens.- GEN_
AI_ USAGE_ OUTPUT_ TOKENS gen_ai.usage.output_tokens.- GEN_
AI_ USAGE_ REASONING gen_ai.usage.reasoning.output_tokens(reasoning/thinking tokens).- RUN_
ID_ ATTR - Framework join key: the run id (also carried on evaluation reports).
- TRACE_
ID_ ATTR - Framework join key: the trace id a run belongs to.