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:
- All
gen_ai.*attribute name constants GenAiProviderandGenAiOperationenumsGenAiSpanBuilderfluent API for creating model call spansGenAiResponseRecorderfor recording response attributesmap_finish_reasonfor provider-specific finish reason mappingtool_call_semconv_spanandagent_run_semconv_spanhelpers
Structs§
- GenAi
Response Recorder - Records response-time attributes on the current span.
- GenAi
Span Builder - Builder for creating model call spans with full OTel GenAI semconv attributes.
Enums§
- GenAi
Operation - Well-known GenAI operation names per OTel semconv.
- GenAi
Provider - Well-known GenAI provider identifiers per OTel semconv registry.
Constants§
- GEN_
AI_ CONTENT_ COMPLETION - The
gen_ai.content.completionevent name. - GEN_
AI_ CONTENT_ PROMPT - The
gen_ai.content.promptevent name. - GEN_
AI_ CONVERSATION_ ID - The
gen_ai.conversation.idattribute. - GEN_
AI_ OPERATION_ NAME - The
gen_ai.operation.nameattribute. - GEN_
AI_ PROVIDER_ NAME - The
gen_ai.provider.nameattribute (v1.41.0+). - GEN_
AI_ REQUEST_ FREQUENCY_ PENALTY - The
gen_ai.request.frequency_penaltyattribute. - GEN_
AI_ REQUEST_ MAX_ TOKENS - The
gen_ai.request.max_tokensattribute. - GEN_
AI_ REQUEST_ MODEL - The
gen_ai.request.modelattribute. - GEN_
AI_ REQUEST_ PRESENCE_ PENALTY - The
gen_ai.request.presence_penaltyattribute. - GEN_
AI_ REQUEST_ STREAM - The
gen_ai.request.streamattribute. - GEN_
AI_ REQUEST_ TEMPERATURE - The
gen_ai.request.temperatureattribute. - GEN_
AI_ REQUEST_ TOP_ K - The
gen_ai.request.top_kattribute. - GEN_
AI_ REQUEST_ TOP_ P - The
gen_ai.request.top_pattribute. - GEN_
AI_ RESPONSE_ FINISH_ REASONS - The
gen_ai.response.finish_reasonsattribute. - GEN_
AI_ RESPONSE_ ID - The
gen_ai.response.idattribute. - GEN_
AI_ RESPONSE_ MODEL - The
gen_ai.response.modelattribute. - GEN_
AI_ SYSTEM - The
gen_ai.systemattribute (legacy, kept for backward compatibility). - GEN_
AI_ TOOL_ CALL_ ID - The
gen_ai.tool.call_idattribute. - GEN_
AI_ TOOL_ NAME - The
gen_ai.tool.nameattribute. - GEN_
AI_ USAGE_ CACHE_ CREATION_ TOKENS - The
gen_ai.usage.cache_creation_tokensattribute. - GEN_
AI_ USAGE_ CACHE_ READ_ TOKENS - The
gen_ai.usage.cache_read_tokensattribute. - GEN_
AI_ USAGE_ INPUT_ TOKENS - The
gen_ai.usage.input_tokensattribute. - GEN_
AI_ USAGE_ OUTPUT_ TOKENS - The
gen_ai.usage.output_tokensattribute. - GEN_
AI_ USAGE_ THINKING_ TOKENS - The
gen_ai.usage.thinking_tokensattribute. - GEN_
AI_ USAGE_ TOTAL_ TOKENS - The
gen_ai.usage.total_tokensattribute.
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.