Skip to main content

Module semconv

Module semconv 

Source
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_tokensGEN_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 for invoke_agent / plan spans.
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 (see EVENT_INFERENCE_DETAILS doc 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 experimental gen_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 of gen_ai.usage.cache_creation.input_tokens (still the published name in registry v1.40). Provider payloads use both spellings (cache_write_input_tokens and the Anthropic legacy cache_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.