From 2b01f4bb0415e32dc8e6aa89f63d7b06921482f9 Mon Sep 17 00:00:00 2001 From: edwardgou-sentry <83961295+edwardgou-sentry@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:53:08 -0400 Subject: [PATCH] fix(spans): Extracts environment from inp spans (#3269) --- .../src/normalize/span/tag_extraction.rs | 8 ++++++++ relay-event-schema/src/protocol/span.rs | 5 +++++ ...action__event__tests__extract_span_metrics_mobile.snap | 2 ++ 3 files changed, 15 insertions(+) diff --git a/relay-event-normalization/src/normalize/span/tag_extraction.rs b/relay-event-normalization/src/normalize/span/tag_extraction.rs index 44fa68cf4d..e537c24e6a 100644 --- a/relay-event-normalization/src/normalize/span/tag_extraction.rs +++ b/relay-event-normalization/src/normalize/span/tag_extraction.rs @@ -480,6 +480,14 @@ pub fn extract_tags( { span_tags.insert(SpanTagKey::ReplayId, replay_id.into()); } + if let Some(environment) = + span.data.value().and_then(|data| data.environment.as_str()) + { + span_tags.insert(SpanTagKey::Environment, environment.into()); + } + if let Some(release) = span.data.value().and_then(|data| data.release.as_str()) { + span_tags.insert(SpanTagKey::Release, release.into()); + } } } } diff --git a/relay-event-schema/src/protocol/span.rs b/relay-event-schema/src/protocol/span.rs index 508a693c03..22209250af 100644 --- a/relay-event-schema/src/protocol/span.rs +++ b/relay-event-schema/src/protocol/span.rs @@ -228,6 +228,10 @@ pub struct SpanData { #[metastructure(field = "environment")] pub environment: Annotated, + /// The release version of the project. + #[metastructure(field = "release")] + pub release: Annotated, + /// The decoded body size of the response (in bytes). #[metastructure(field = "http.decoded_response_content_length")] pub http_decoded_response_content_length: Annotated, @@ -559,6 +563,7 @@ mod tests { "mysql", ), environment: ~, + release: ~, http_decoded_response_content_length: ~, http_request_method: ~, http_response_content_length: ~, diff --git a/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__extract_span_metrics_mobile.snap b/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__extract_span_metrics_mobile.snap index 20df347a82..1383571370 100644 --- a/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__extract_span_metrics_mobile.snap +++ b/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__extract_span_metrics_mobile.snap @@ -311,6 +311,7 @@ expression: "(&event.value().unwrap().spans, metrics)" db_operation: ~, db_system: ~, environment: ~, + release: ~, http_decoded_response_content_length: ~, http_request_method: ~, http_response_content_length: ~, @@ -383,6 +384,7 @@ expression: "(&event.value().unwrap().spans, metrics)" db_operation: ~, db_system: ~, environment: ~, + release: ~, http_decoded_response_content_length: ~, http_request_method: ~, http_response_content_length: ~,