Skip to main content

Module semconv

Module semconv 

Source
Available on crate features genai-semconv and telemetry only.
Expand description

OpenTelemetry GenAI Semantic Convention attribute constants and helpers.

Based on OTel Semantic Conventions v1.41.0: https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/

This module provides:

Structs§

GenAiResponseRecorder
Records response-time attributes on the current span.
GenAiSpanBuilder
Builder for creating model call spans with full OTel GenAI semconv attributes.

Enums§

GenAiOperation
Well-known GenAI operation names per OTel semconv.
GenAiProvider
Well-known GenAI provider identifiers per OTel semconv registry.

Constants§

GEN_AI_CONTENT_COMPLETION
The gen_ai.content.completion event name.
GEN_AI_CONTENT_PROMPT
The gen_ai.content.prompt event name.
GEN_AI_CONVERSATION_ID
The gen_ai.conversation.id attribute.
GEN_AI_OPERATION_NAME
The gen_ai.operation.name attribute.
GEN_AI_PROVIDER_NAME
The gen_ai.provider.name attribute (v1.41.0+).
GEN_AI_REQUEST_FREQUENCY_PENALTY
The gen_ai.request.frequency_penalty attribute.
GEN_AI_REQUEST_MAX_TOKENS
The gen_ai.request.max_tokens attribute.
GEN_AI_REQUEST_MODEL
The gen_ai.request.model attribute.
GEN_AI_REQUEST_PRESENCE_PENALTY
The gen_ai.request.presence_penalty attribute.
GEN_AI_REQUEST_STREAM
The gen_ai.request.stream attribute.
GEN_AI_REQUEST_TEMPERATURE
The gen_ai.request.temperature attribute.
GEN_AI_REQUEST_TOP_K
The gen_ai.request.top_k attribute.
GEN_AI_REQUEST_TOP_P
The gen_ai.request.top_p attribute.
GEN_AI_RESPONSE_FINISH_REASONS
The gen_ai.response.finish_reasons attribute.
GEN_AI_RESPONSE_ID
The gen_ai.response.id attribute.
GEN_AI_RESPONSE_MODEL
The gen_ai.response.model attribute.
GEN_AI_SYSTEM
The gen_ai.system attribute (legacy, kept for backward compatibility).
GEN_AI_TOOL_CALL_ID
The gen_ai.tool.call_id attribute.
GEN_AI_TOOL_NAME
The gen_ai.tool.name attribute.
GEN_AI_USAGE_CACHE_CREATION_TOKENS
The gen_ai.usage.cache_creation_tokens attribute.
GEN_AI_USAGE_CACHE_READ_TOKENS
The gen_ai.usage.cache_read_tokens attribute.
GEN_AI_USAGE_INPUT_TOKENS
The gen_ai.usage.input_tokens attribute.
GEN_AI_USAGE_OUTPUT_TOKENS
The gen_ai.usage.output_tokens attribute.
GEN_AI_USAGE_THINKING_TOKENS
The gen_ai.usage.thinking_tokens attribute.
GEN_AI_USAGE_TOTAL_TOKENS
The gen_ai.usage.total_tokens attribute.

Functions§

agent_run_semconv_span
Create a span for agent execution with conversation ID.
map_finish_reason
Maps provider-specific finish reason strings to OTel semconv values.
tool_call_semconv_span
Create a span for tool execution with GenAI semconv attributes.