diff --git a/CHANGELOG.md b/CHANGELOG.md index 41c545f0c6..28279f8bc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Metric size limit per metric default changed to 1mib. ([#5779](https://github.com/getsentry/relay/pull/5779)) - Use `gen_ai.function_id` as a fallback for `gen_ai.agent.name`. ([#5776](https://github.com/getsentry/relay/pull/5776)) - Add `gen_ai.input.messages` and `gen_ai.output.messages` as distinct fields for SpanData. ([#5797](https://github.com/getsentry/relay/pull/5797)) +- Update several `gen_ai` attributes to their latest representation. ([#5798](https://github.com/getsentry/relay/pull/5798)) - Extract `http.query` and `url.query` attributes from `query_string` in transactions' request context. ([#5784](https://github.com/getsentry/relay/pull/5784)) **Internal**: diff --git a/relay-conventions/src/consts.rs b/relay-conventions/src/consts.rs index 575d967101..74e3eb05bb 100644 --- a/relay-conventions/src/consts.rs +++ b/relay-conventions/src/consts.rs @@ -42,7 +42,7 @@ convention_attributes!( GEN_AI_REQUEST_MODEL => "gen_ai.request.model", GEN_AI_RESPONSE_MODEL => "gen_ai.response.model", GEN_AI_RESPONSE_TPS => "gen_ai.response.tokens_per_second", - GEN_AI_SYSTEM => "gen_ai.system", + GEN_AI_PROVIDER_NAME => "gen_ai.provider.name", GEN_AI_USAGE_INPUT_CACHED_TOKENS => "gen_ai.usage.input_tokens.cached", GEN_AI_USAGE_INPUT_CACHE_WRITE_TOKENS => "gen_ai.usage.input_tokens.cache_write", GEN_AI_USAGE_INPUT_TOKENS => "gen_ai.usage.input_tokens", diff --git a/relay-event-schema/src/protocol/span.rs b/relay-event-schema/src/protocol/span.rs index 90cc716c33..a22ef06f4e 100644 --- a/relay-event-schema/src/protocol/span.rs +++ b/relay-event-schema/src/protocol/span.rs @@ -553,51 +553,46 @@ pub struct SpanData { #[metastructure(field = "gen_ai.cost.output_tokens", pii = "maybe")] pub gen_ai_cost_output_tokens: Annotated, - /// Prompt passed to LLM (Vercel AI SDK) - #[metastructure(field = "gen_ai.prompt", pii = "maybe")] - pub gen_ai_prompt: Annotated, - - /// Prompt passed to LLM + /// The input messages to the model call. #[metastructure( - field = "gen_ai.request.messages", + field = "gen_ai.input.messages", pii = "maybe", + legacy_alias = "gen_ai.prompt", + legacy_alias = "gen_ai.request.messages", legacy_alias = "ai.prompt.messages" )] - pub gen_ai_request_messages: Annotated, + pub gen_ai_input_messages: Annotated, - /// Tool call arguments + /// Tool call arguments. #[metastructure( - field = "gen_ai.tool.input", + field = "gen_ai.tool.call.arguments", pii = "maybe", + legacy_alias = "gen_ai.tool.input", legacy_alias = "ai.toolCall.args" )] - pub gen_ai_tool_input: Annotated, + pub gen_ai_tool_call_arguments: Annotated, - /// Tool call result + /// Tool call result. #[metastructure( - field = "gen_ai.tool.output", + field = "gen_ai.tool.call.result", pii = "maybe", + legacy_alias = "gen_ai.tool.output", legacy_alias = "ai.toolCall.result" )] - pub gen_ai_tool_output: Annotated, + pub gen_ai_tool_call_result: Annotated, - /// LLM decisions to use tools + /// The output messages from the model call. #[metastructure( - field = "gen_ai.response.tool_calls", + field = "gen_ai.output.messages", + legacy_alias = "gen_ai.response.tool_calls", legacy_alias = "ai.response.toolCalls", legacy_alias = "ai.tool_calls", - pii = "maybe" - )] - pub gen_ai_response_tool_calls: Annotated, - - /// LLM response text (Vercel AI, generateText) - #[metastructure( - field = "gen_ai.response.text", + legacy_alias = "gen_ai.response.text", legacy_alias = "ai.response.text", legacy_alias = "ai.responses", pii = "maybe" )] - pub gen_ai_response_text: Annotated, + pub gen_ai_output_messages: Annotated, /// LLM response object (Vercel AI, generateObject) #[metastructure(field = "gen_ai.response.object", pii = "maybe")] @@ -615,13 +610,14 @@ pub struct SpanData { #[metastructure(field = "gen_ai.response.time_to_first_token", pii = "maybe")] pub gen_ai_response_time_to_first_token: Annotated, - /// The available tools for a request to an LLM + /// The tool definitions available for a request to an LLM. #[metastructure( - field = "gen_ai.request.available_tools", + field = "gen_ai.tool.definitions", + legacy_alias = "gen_ai.request.available_tools", legacy_alias = "ai.tools", pii = "maybe" )] - pub gen_ai_request_available_tools: Annotated, + pub gen_ai_tool_definitions: Annotated, /// The frequency penalty for a request to an LLM #[metastructure( @@ -653,20 +649,25 @@ pub struct SpanData { #[metastructure(field = "gen_ai.request.top_p", legacy_alias = "ai.top_p")] pub gen_ai_request_top_p: Annotated, - /// The finish reason for a response from an LLM + /// The finish reasons for a response from an LLM. #[metastructure( - field = "gen_ai.response.finish_reason", + field = "gen_ai.response.finish_reasons", + legacy_alias = "gen_ai.response.finish_reason", legacy_alias = "ai.finish_reason" )] - pub gen_ai_response_finish_reason: Annotated, + pub gen_ai_response_finish_reasons: Annotated, /// The unique identifier for a response from an LLM #[metastructure(field = "gen_ai.response.id", legacy_alias = "ai.generation_id")] pub gen_ai_response_id: Annotated, - /// The GenAI system identifier - #[metastructure(field = "gen_ai.system", legacy_alias = "ai.model.provider")] - pub gen_ai_system: Annotated, + /// The GenAI provider name. + #[metastructure( + field = "gen_ai.provider.name", + legacy_alias = "gen_ai.system", + legacy_alias = "ai.model.provider" + )] + pub gen_ai_provider_name: Annotated, /// The system instructions passed to the model. #[metastructure( @@ -700,14 +701,6 @@ pub struct SpanData { #[metastructure(field = "gen_ai.function_id", pii = "maybe")] pub gen_ai_function_id: Annotated, - /// The input messages to the model call. - #[metastructure(field = "gen_ai.input.messages", pii = "maybe")] - pub gen_ai_input_messages: Annotated, - - /// The output messages from the model call. - #[metastructure(field = "gen_ai.output.messages", pii = "maybe")] - pub gen_ai_output_messages: Annotated, - /// The result of the MCP prompt. #[metastructure(field = "mcp.prompt.result", pii = "maybe")] pub mcp_prompt_result: Annotated, @@ -1526,34 +1519,30 @@ mod tests { gen_ai_cost_total_tokens: ~, gen_ai_cost_input_tokens: ~, gen_ai_cost_output_tokens: ~, - gen_ai_prompt: ~, - gen_ai_request_messages: ~, - gen_ai_tool_input: ~, - gen_ai_tool_output: ~, - gen_ai_response_tool_calls: ~, - gen_ai_response_text: ~, + gen_ai_input_messages: ~, + gen_ai_tool_call_arguments: ~, + gen_ai_tool_call_result: ~, + gen_ai_output_messages: ~, gen_ai_response_object: ~, gen_ai_response_streaming: ~, gen_ai_response_tokens_per_second: ~, gen_ai_response_time_to_first_token: ~, - gen_ai_request_available_tools: ~, + gen_ai_tool_definitions: ~, gen_ai_request_frequency_penalty: ~, gen_ai_request_presence_penalty: ~, gen_ai_request_seed: ~, gen_ai_request_temperature: ~, gen_ai_request_top_k: ~, gen_ai_request_top_p: ~, - gen_ai_response_finish_reason: ~, + gen_ai_response_finish_reasons: ~, gen_ai_response_id: ~, - gen_ai_system: ~, + gen_ai_provider_name: ~, gen_ai_system_instructions: ~, gen_ai_tool_name: ~, gen_ai_operation_name: ~, gen_ai_operation_type: ~, gen_ai_agent_name: ~, gen_ai_function_id: ~, - gen_ai_input_messages: ~, - gen_ai_output_messages: ~, mcp_prompt_result: ~, mcp_tool_result_content: ~, browser_name: ~, diff --git a/relay-event-schema/src/protocol/span/convert.rs b/relay-event-schema/src/protocol/span/convert.rs index 82b123673d..636f4279b9 100644 --- a/relay-event-schema/src/protocol/span/convert.rs +++ b/relay-event-schema/src/protocol/span/convert.rs @@ -183,34 +183,30 @@ mod tests { gen_ai_cost_total_tokens: ~, gen_ai_cost_input_tokens: ~, gen_ai_cost_output_tokens: ~, - gen_ai_prompt: ~, - gen_ai_request_messages: ~, - gen_ai_tool_input: ~, - gen_ai_tool_output: ~, - gen_ai_response_tool_calls: ~, - gen_ai_response_text: ~, + gen_ai_input_messages: ~, + gen_ai_tool_call_arguments: ~, + gen_ai_tool_call_result: ~, + gen_ai_output_messages: ~, gen_ai_response_object: ~, gen_ai_response_streaming: ~, gen_ai_response_tokens_per_second: ~, gen_ai_response_time_to_first_token: ~, - gen_ai_request_available_tools: ~, + gen_ai_tool_definitions: ~, gen_ai_request_frequency_penalty: ~, gen_ai_request_presence_penalty: ~, gen_ai_request_seed: ~, gen_ai_request_temperature: ~, gen_ai_request_top_k: ~, gen_ai_request_top_p: ~, - gen_ai_response_finish_reason: ~, + gen_ai_response_finish_reasons: ~, gen_ai_response_id: ~, - gen_ai_system: ~, + gen_ai_provider_name: ~, gen_ai_system_instructions: ~, gen_ai_tool_name: ~, gen_ai_operation_name: ~, gen_ai_operation_type: ~, gen_ai_agent_name: ~, gen_ai_function_id: ~, - gen_ai_input_messages: ~, - gen_ai_output_messages: ~, mcp_prompt_result: ~, mcp_tool_result_content: ~, browser_name: "Chrome", diff --git a/relay-pii/src/convert.rs b/relay-pii/src/convert.rs index a0a523d665..6a8a74ef1b 100644 --- a/relay-pii/src/convert.rs +++ b/relay-pii/src/convert.rs @@ -83,28 +83,27 @@ static REPLACE_ONLY_SELECTOR: LazyLock = LazyLock::new(|| { [ "$logentry.formatted", "$log.body", - "$span.data.'gen_ai.prompt'", + "$span.data.'gen_ai.input.messages'", + "attributes.'gen_ai.input.messages'.value", "attributes.'gen_ai.prompt'.value", - "$span.data.'gen_ai.request.messages'", "attributes.'gen_ai.request.messages'.value", - "$span.data.'gen_ai.tool.input'", + "$span.data.'gen_ai.tool.call.arguments'", + "attributes.'gen_ai.tool.call.arguments'.value", "attributes.'gen_ai.tool.input'.value", - "$span.data.'gen_ai.tool.output'", + "$span.data.'gen_ai.tool.call.result'", + "attributes.'gen_ai.tool.call.result'.value", "attributes.'gen_ai.tool.output'.value", - "$span.data.'gen_ai.response.tool_calls'", + "$span.data.'gen_ai.output.messages'", + "attributes.'gen_ai.output.messages'.value", "attributes.'gen_ai.response.tool_calls'.value", - "$span.data.'gen_ai.response.text'", "attributes.'gen_ai.response.text'.value", "$span.data.'gen_ai.response.object'", "attributes.'gen_ai.response.object'.value", - "$span.data.'gen_ai.request.available_tools'", + "$span.data.'gen_ai.tool.definitions'", + "attributes.'gen_ai.tool.definitions'.value", "attributes.'gen_ai.request.available_tools'.value", "$span.data.'gen_ai.tool.name'", "attributes.'gen_ai.tool.name'.value", - "$span.data.'gen_ai.input.messages'", - "attributes.'gen_ai.input.messages'.value", - "$span.data.'gen_ai.output.messages'", - "attributes.'gen_ai.output.messages'.value", "$span.data.'mcp.prompt.result'", "attributes.'mcp.prompt.result'.value", "$span.data.'mcp.tool.result.content'", @@ -362,7 +361,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv "$http.env.REMOTE_ADDR || $user.ip_address || $sdk.client_ip || $span.sentry_tags.'user.ip'": [ "@anything:remove" ], - "$logentry.formatted || $log.body || $span.data.'gen_ai.prompt' || attributes.'gen_ai.prompt'.value || $span.data.'gen_ai.request.messages' || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.input' || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.output' || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.response.tool_calls' || attributes.'gen_ai.response.tool_calls'.value || $span.data.'gen_ai.response.text' || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.request.available_tools' || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ + "$logentry.formatted || $log.body || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || attributes.'gen_ai.prompt'.value || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.call.arguments' || attributes.'gen_ai.tool.call.arguments'.value || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.call.result' || attributes.'gen_ai.tool.call.result'.value || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || attributes.'gen_ai.response.tool_calls'.value || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.tool.definitions' || attributes.'gen_ai.tool.definitions'.value || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ "@email:replace", "@creditcard:replace", "@iban:replace", @@ -394,7 +393,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv "$http.env.REMOTE_ADDR || $user.ip_address || $sdk.client_ip || $span.sentry_tags.'user.ip'": [ "@anything:remove" ], - "$logentry.formatted || $log.body || $span.data.'gen_ai.prompt' || attributes.'gen_ai.prompt'.value || $span.data.'gen_ai.request.messages' || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.input' || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.output' || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.response.tool_calls' || attributes.'gen_ai.response.tool_calls'.value || $span.data.'gen_ai.response.text' || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.request.available_tools' || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ + "$logentry.formatted || $log.body || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || attributes.'gen_ai.prompt'.value || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.call.arguments' || attributes.'gen_ai.tool.call.arguments'.value || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.call.result' || attributes.'gen_ai.tool.call.result'.value || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || attributes.'gen_ai.response.tool_calls'.value || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.tool.definitions' || attributes.'gen_ai.tool.definitions'.value || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ "@email:replace", "@creditcard:replace", "@iban:replace", @@ -437,7 +436,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv "$http.env.REMOTE_ADDR || $user.ip_address || $sdk.client_ip || $span.sentry_tags.'user.ip'": [ "@anything:remove" ], - "$logentry.formatted || $log.body || $span.data.'gen_ai.prompt' || attributes.'gen_ai.prompt'.value || $span.data.'gen_ai.request.messages' || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.input' || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.output' || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.response.tool_calls' || attributes.'gen_ai.response.tool_calls'.value || $span.data.'gen_ai.response.text' || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.request.available_tools' || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ + "$logentry.formatted || $log.body || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || attributes.'gen_ai.prompt'.value || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.call.arguments' || attributes.'gen_ai.tool.call.arguments'.value || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.call.result' || attributes.'gen_ai.tool.call.result'.value || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || attributes.'gen_ai.response.tool_calls'.value || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.tool.definitions' || attributes.'gen_ai.tool.definitions'.value || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ "@email:replace", "@creditcard:replace", "@iban:replace", @@ -469,7 +468,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv "$http.env.REMOTE_ADDR || $user.ip_address || $sdk.client_ip || $span.sentry_tags.'user.ip'": [ "@anything:remove" ], - "$logentry.formatted || $log.body || $span.data.'gen_ai.prompt' || attributes.'gen_ai.prompt'.value || $span.data.'gen_ai.request.messages' || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.input' || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.output' || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.response.tool_calls' || attributes.'gen_ai.response.tool_calls'.value || $span.data.'gen_ai.response.text' || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.request.available_tools' || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ + "$logentry.formatted || $log.body || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || attributes.'gen_ai.prompt'.value || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.call.arguments' || attributes.'gen_ai.tool.call.arguments'.value || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.call.result' || attributes.'gen_ai.tool.call.result'.value || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || attributes.'gen_ai.response.tool_calls'.value || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.tool.definitions' || attributes.'gen_ai.tool.definitions'.value || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ "@email:replace", "@creditcard:replace", "@iban:replace", @@ -1390,7 +1389,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv "$http.env.REMOTE_ADDR || $user.ip_address || $sdk.client_ip || $span.sentry_tags.'user.ip'": [ "@anything:remove" ], - "$logentry.formatted || $log.body || $span.data.'gen_ai.prompt' || attributes.'gen_ai.prompt'.value || $span.data.'gen_ai.request.messages' || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.input' || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.output' || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.response.tool_calls' || attributes.'gen_ai.response.tool_calls'.value || $span.data.'gen_ai.response.text' || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.request.available_tools' || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ + "$logentry.formatted || $log.body || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || attributes.'gen_ai.prompt'.value || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.call.arguments' || attributes.'gen_ai.tool.call.arguments'.value || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.call.result' || attributes.'gen_ai.tool.call.result'.value || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || attributes.'gen_ai.response.tool_calls'.value || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.tool.definitions' || attributes.'gen_ai.tool.definitions'.value || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ "@email:replace", "@creditcard:replace", "@iban:replace", @@ -1992,7 +1991,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv "spans": [ { "data": { - "gen_ai.prompt": "Buy me a drink with my creditcard [creditcard]" + "gen_ai.input.messages": "Buy me a drink with my creditcard [creditcard]" } } ], @@ -2000,7 +1999,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv "spans": { "0": { "data": { - "gen_ai.prompt": { + "gen_ai.input.messages": { "": { "rem": [ [ diff --git a/relay-pii/src/snapshots/relay_pii__convert__tests__regression_more_odd_keys.snap b/relay-pii/src/snapshots/relay_pii__convert__tests__regression_more_odd_keys.snap index 94f444fc7f..cd56a88440 100644 --- a/relay-pii/src/snapshots/relay_pii__convert__tests__regression_more_odd_keys.snap +++ b/relay-pii/src/snapshots/relay_pii__convert__tests__regression_more_odd_keys.snap @@ -11,7 +11,7 @@ expression: pii_config "$http.env.REMOTE_ADDR || $user.ip_address || $sdk.client_ip || $span.sentry_tags.'user.ip'": [ "@anything:remove" ], - "$logentry.formatted || $log.body || $span.data.'gen_ai.prompt' || attributes.'gen_ai.prompt'.value || $span.data.'gen_ai.request.messages' || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.input' || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.output' || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.response.tool_calls' || attributes.'gen_ai.response.tool_calls'.value || $span.data.'gen_ai.response.text' || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.request.available_tools' || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ + "$logentry.formatted || $log.body || $span.data.'gen_ai.input.messages' || attributes.'gen_ai.input.messages'.value || attributes.'gen_ai.prompt'.value || attributes.'gen_ai.request.messages'.value || $span.data.'gen_ai.tool.call.arguments' || attributes.'gen_ai.tool.call.arguments'.value || attributes.'gen_ai.tool.input'.value || $span.data.'gen_ai.tool.call.result' || attributes.'gen_ai.tool.call.result'.value || attributes.'gen_ai.tool.output'.value || $span.data.'gen_ai.output.messages' || attributes.'gen_ai.output.messages'.value || attributes.'gen_ai.response.tool_calls'.value || attributes.'gen_ai.response.text'.value || $span.data.'gen_ai.response.object' || attributes.'gen_ai.response.object'.value || $span.data.'gen_ai.tool.definitions' || attributes.'gen_ai.tool.definitions'.value || attributes.'gen_ai.request.available_tools'.value || $span.data.'gen_ai.tool.name' || attributes.'gen_ai.tool.name'.value || $span.data.'mcp.prompt.result' || attributes.'mcp.prompt.result'.value || $span.data.'mcp.tool.result.content' || attributes.'mcp.tool.result.content'.value": [ "@email:replace", "@creditcard:replace", "@iban:replace", diff --git a/relay-spans/src/v2_to_v1.rs b/relay-spans/src/v2_to_v1.rs index cb0f566da1..d712b2eb97 100644 --- a/relay-spans/src/v2_to_v1.rs +++ b/relay-spans/src/v2_to_v1.rs @@ -252,7 +252,8 @@ pub fn derive_op_for_v2_span(attributes: &Annotated) -> String { return String::from("db"); } - if attributes.contains_key(GEN_AI_SYSTEM) { + // TODO: `gen_ai.system` is deprecated. This should probably be taken care of during normalization. + if attributes.contains_key(GEN_AI_PROVIDER_NAME) || attributes.contains_key("gen_ai.system") { return String::from("gen_ai"); } @@ -1019,7 +1020,7 @@ mod tests { "trace_id": "89143b0763095bd9c9955e8175d1fb23", "status": "unknown", "data": { - "gen_ai.system": "openai", + "gen_ai.provider.name": "openai", "gen_ai.agent.name": "Seer" }, "kind": "client" diff --git a/tests/integration/test_ai.py b/tests/integration/test_ai.py index 51c765a3ea..d355c06c1a 100644 --- a/tests/integration/test_ai.py +++ b/tests/integration/test_ai.py @@ -393,9 +393,9 @@ def test_ai_spans_example_transaction( "gen_ai.agent.name": {"type": "string", "value": "weather-chat"}, "gen_ai.function_id": {"type": "string", "value": "weather-chat"}, "gen_ai.operation.type": {"type": "string", "value": "agent"}, - "gen_ai.prompt": {"type": "string", "value": "Weather Prompt"}, + "gen_ai.input.messages": {"type": "string", "value": "Weather Prompt"}, "gen_ai.response.model": {"type": "string", "value": "gpt-4o"}, - "gen_ai.response.text": { + "gen_ai.output.messages": { "type": "string", "value": "True. \n\n- London: 61°F \n- San Francisco: 13°C", }, @@ -482,11 +482,11 @@ def test_ai_spans_example_transaction( "gen_ai.agent.name": {"type": "string", "value": "weather-chat"}, "gen_ai.function_id": {"type": "string", "value": "weather-chat"}, "gen_ai.operation.type": {"type": "string", "value": "ai_client"}, - "gen_ai.request.available_tools": { + "gen_ai.tool.definitions": { "type": "string", "value": '["tools1"]', }, - "gen_ai.request.messages": { + "gen_ai.input.messages": { "type": "string", "value": "Another weather prompt", }, @@ -504,11 +504,11 @@ def test_ai_spans_example_transaction( "value": "gpt-4o-2024-08-06", }, "gen_ai.response.tokens_per_second": {"type": "double", "value": 92.0}, - "gen_ai.response.tool_calls": { + "gen_ai.output.messages": { "type": "string", "value": "some_tool_calls", }, - "gen_ai.system": {"type": "string", "value": "openai.responses"}, + "gen_ai.provider.name": {"type": "string", "value": "openai.responses"}, "gen_ai.usage.input_tokens": {"type": "integer", "value": 37}, "gen_ai.usage.output_tokens": {"type": "integer", "value": 46}, "gen_ai.usage.total_tokens": {"type": "integer", "value": 83}, @@ -684,12 +684,12 @@ def test_ai_spans_example_transaction( "type": "string", "value": "call_jRcFbOh5zNVeV2l2mEqpRiI4", }, - "gen_ai.tool.input": { + "gen_ai.tool.call.arguments": { "type": "string", "value": '{"city":"San Francisco"}', }, "gen_ai.tool.name": {"type": "string", "value": "getWeather"}, - "gen_ai.tool.output": { + "gen_ai.tool.call.result": { "type": "string", "value": '{"location":"San Francisco, ' "United States of " @@ -826,9 +826,12 @@ def test_ai_spans_example_transaction( "type": "string", "value": "call_yXdgMJXsotHOn19VdlDjrc7c", }, - "gen_ai.tool.input": {"type": "string", "value": '{"city":"London"}'}, + "gen_ai.tool.call.arguments": { + "type": "string", + "value": '{"city":"London"}', + }, "gen_ai.tool.name": {"type": "string", "value": "getWeather"}, - "gen_ai.tool.output": { + "gen_ai.tool.call.result": { "type": "string", "value": '{"location":"London, United ' 'Kingdom","temperature":"16°C ' @@ -971,11 +974,11 @@ def test_ai_spans_example_transaction( "gen_ai.agent.name": {"type": "string", "value": "weather-chat"}, "gen_ai.function_id": {"type": "string", "value": "weather-chat"}, "gen_ai.operation.type": {"type": "string", "value": "ai_client"}, - "gen_ai.request.available_tools": { + "gen_ai.tool.definitions": { "type": "string", "value": '["tool_1"]', }, - "gen_ai.request.messages": { + "gen_ai.input.messages": { "type": "string", "value": "Some AI Prompt about " "the Wheather", }, @@ -992,7 +995,7 @@ def test_ai_spans_example_transaction( "type": "string", "value": "gpt-4o-2024-08-06", }, - "gen_ai.response.text": { + "gen_ai.output.messages": { "type": "string", "value": "True. \n" "\n" @@ -1000,7 +1003,7 @@ def test_ai_spans_example_transaction( "- San Francisco: 13°C", }, "gen_ai.response.tokens_per_second": {"type": "double", "value": 38.0}, - "gen_ai.system": {"type": "string", "value": "openai.responses"}, + "gen_ai.provider.name": {"type": "string", "value": "openai.responses"}, "gen_ai.usage.input_tokens": {"type": "integer", "value": 208}, "gen_ai.usage.output_tokens": {"type": "integer", "value": 19}, "gen_ai.usage.total_tokens": {"type": "integer", "value": 227},