Skip to main content

aether_telemetry/
genai_constants.rs

1// Upstream GenAI semantic conventions are still in development and marked
2// deprecated until they're published in a stable crate. This module
3// centralizes constants so other modules stay clean.
4#![allow(deprecated)]
5
6use opentelemetry::InstrumentationScope;
7pub use opentelemetry_semantic_conventions::SCHEMA_URL as GENAI_SEMCONV_SCHEMA_URL;
8use opentelemetry_semantic_conventions::{attribute, metric};
9
10pub const ERROR_TYPE: &str = attribute::ERROR_TYPE;
11pub const GEN_AI_AGENT_NAME: &str = attribute::GEN_AI_AGENT_NAME;
12pub const GEN_AI_INPUT_MESSAGES: &str = attribute::GEN_AI_INPUT_MESSAGES;
13pub const GEN_AI_OPERATION_NAME: &str = attribute::GEN_AI_OPERATION_NAME;
14pub const GEN_AI_OUTPUT_MESSAGES: &str = attribute::GEN_AI_OUTPUT_MESSAGES;
15pub const GEN_AI_PROVIDER_NAME: &str = attribute::GEN_AI_PROVIDER_NAME;
16pub const GEN_AI_REQUEST_MODEL: &str = attribute::GEN_AI_REQUEST_MODEL;
17pub const GEN_AI_REQUEST_STREAM: &str = attribute::GEN_AI_REQUEST_STREAM;
18pub const GEN_AI_RESPONSE_FINISH_REASONS: &str = attribute::GEN_AI_RESPONSE_FINISH_REASONS;
19pub const GEN_AI_RESPONSE_TIME_TO_FIRST_CHUNK: &str = attribute::GEN_AI_RESPONSE_TIME_TO_FIRST_CHUNK;
20pub const GEN_AI_SYSTEM_INSTRUCTIONS: &str = attribute::GEN_AI_SYSTEM_INSTRUCTIONS;
21pub const GEN_AI_TOKEN_TYPE: &str = attribute::GEN_AI_TOKEN_TYPE;
22pub const GEN_AI_TOOL_CALL_ARGUMENTS: &str = attribute::GEN_AI_TOOL_CALL_ARGUMENTS;
23pub const GEN_AI_TOOL_CALL_ID: &str = attribute::GEN_AI_TOOL_CALL_ID;
24pub const GEN_AI_TOOL_CALL_RESULT: &str = attribute::GEN_AI_TOOL_CALL_RESULT;
25pub const GEN_AI_TOOL_DEFINITIONS: &str = attribute::GEN_AI_TOOL_DEFINITIONS;
26pub const GEN_AI_TOOL_NAME: &str = attribute::GEN_AI_TOOL_NAME;
27pub const GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS: &str = attribute::GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS;
28pub const GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS: &str = attribute::GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS;
29pub const GEN_AI_USAGE_INPUT_TOKENS: &str = attribute::GEN_AI_USAGE_INPUT_TOKENS;
30pub const GEN_AI_USAGE_OUTPUT_TOKENS: &str = attribute::GEN_AI_USAGE_OUTPUT_TOKENS;
31pub const GEN_AI_USAGE_REASONING_OUTPUT_TOKENS: &str = attribute::GEN_AI_USAGE_REASONING_OUTPUT_TOKENS;
32pub const SERVICE_VERSION: &str = attribute::SERVICE_VERSION;
33
34pub const GEN_AI_CLIENT_OPERATION_DURATION: &str = metric::GEN_AI_CLIENT_OPERATION_DURATION;
35pub const GEN_AI_CLIENT_OPERATION_TIME_PER_OUTPUT_CHUNK: &str = metric::GEN_AI_CLIENT_OPERATION_TIME_PER_OUTPUT_CHUNK;
36pub const GEN_AI_CLIENT_OPERATION_TIME_TO_FIRST_CHUNK: &str = metric::GEN_AI_CLIENT_OPERATION_TIME_TO_FIRST_CHUNK;
37pub const GEN_AI_CLIENT_TOKEN_USAGE: &str = metric::GEN_AI_CLIENT_TOKEN_USAGE;
38
39pub const GENAI_RESPONSE_START_EVENT: &str = "gen_ai.response.start";
40pub const GENAI_TOOL_CALL_START_EVENT: &str = "gen_ai.tool_call.start";
41pub const MCP_METHOD_NAME: &str = "mcp.method.name";
42pub const MCP_TOOL_NAME: &str = "mcp.tool.name";
43pub const MESSAGE_ID: &str = "message.id";
44pub const TOOL_CALL_ID: &str = "tool_call.id";
45pub const TOOL_CALL_NAME: &str = "tool_call.name";
46pub const LLM_ATTEMPT: &str = "aether.llm.attempt";
47pub const LLM_PURPOSE: &str = "aether.llm.purpose";
48pub const AETHER_INPUT_MESSAGES_SHA256: &str = "aether.llm.input_messages.sha256";
49pub const AETHER_SYSTEM_INSTRUCTIONS_SHA256: &str = "aether.llm.system_instructions.sha256";
50pub const AI_INPUT_TOKEN_PRICE: &str = "$ai_input_token_price";
51pub const AI_OUTPUT_TOKEN_PRICE: &str = "$ai_output_token_price";
52pub const AI_CACHE_READ_TOKEN_PRICE: &str = "$ai_cache_read_token_price";
53pub const AI_CACHE_WRITE_TOKEN_PRICE: &str = "$ai_cache_write_token_price";
54pub const AI_REASONING_TOKENS: &str = "$ai_reasoning_tokens";
55
56pub fn genai_instrumentation_scope(version: impl Into<String>) -> InstrumentationScope {
57    InstrumentationScope::builder("aether.genai")
58        .with_version(version.into())
59        .with_schema_url(GENAI_SEMCONV_SCHEMA_URL)
60        .build()
61}