diff --git a/CHANGELOG.md b/CHANGELOG.md index feb29d1b484..c235d8887c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Retry failing objectstore requests. ([#5836](https://github.com/getsentry/relay/pull/5836)) - Add mobile normalizations to SpanV2 processing pipeline (mobile tag, main thread, outlier filtering, app start backfill from V1 transactions, device class). ([#5824](https://github.com/getsentry/relay/pull/5824)) - Remove the deprecated `aiModelCosts` global config, superseded by `aiModelMetadata`. ([#5862](https://github.com/getsentry/relay/pull/5862)) +- Make `_performance_issues_spans` a top-level field. ([#5870](https://github.com/getsentry/relay/pull/5870)) **Bug Fixes**: diff --git a/relay-server/src/processing/legacy_spans/store.rs b/relay-server/src/processing/legacy_spans/store.rs index 791cde6ba6a..d9b48383b97 100644 --- a/relay-server/src/processing/legacy_spans/store.rs +++ b/relay-server/src/processing/legacy_spans/store.rs @@ -23,6 +23,11 @@ macro_rules! required { /// Converts a [`Span`] into a [`StoreSpanV2`] to be sent to Kafka. pub fn convert(span: Annotated, retentions: Retention) -> Result> { + let performance_issues_spans = span + .value() + .and_then(|s| s.performance_issues_spans.value().copied()) + .unwrap_or(false); + let span = span.map_value(relay_spans::span_v1_to_span_v2); let span = required!(span); @@ -30,6 +35,7 @@ pub fn convert(span: Annotated, retentions: Retention) -> Result Result> routing_key, retention_days: ctx.retention.standard, downsampled_retention_days: ctx.retention.downsampled, + performance_issues_spans: false, item: span, })) } diff --git a/relay-server/src/services/store.rs b/relay-server/src/services/store.rs index 4fba25dbdd3..e7adea9423e 100644 --- a/relay-server/src/services/store.rs +++ b/relay-server/src/services/store.rs @@ -137,6 +137,10 @@ pub struct StoreSpanV2 { pub retention_days: u16, /// Downsampled retention of the span. pub downsampled_retention_days: u16, + /// Temporary flag controlling where performance issues are detected. + /// + /// Travels on the Kafka envelope (`SpanMeta`) rather than the SpanV2 body. + pub performance_issues_spans: bool, /// The final Sentry compatible span item. pub item: SpanV2, } @@ -788,6 +792,7 @@ impl StoreService { downsampled_retention_days: message.downsampled_retention_days, received: datetime_to_timestamp(received_at), accepted_outcome_emitted: relay_emits_accepted_outcome, + performance_issues_spans: message.performance_issues_spans, }; message.try_accept(|span| { @@ -1677,6 +1682,17 @@ struct SpanMeta { downsampled_retention_days: u16, /// Indicates whether Relay already emitted an accepted outcome or if EAP still needs to emit it. accepted_outcome_emitted: bool, + /// Temporary flag that controls where performance issues are detected. + /// + /// When the flag is set to true, performance issues will be detected on this span provided it + /// is a root (segment) instead of the transaction event. + /// + /// Only set on root spans extracted from transactions. + #[serde( + rename = "_performance_issues_spans", + skip_serializing_if = "std::ops::Not::not" + )] + performance_issues_spans: bool, } #[derive(Clone, Debug, Serialize)] diff --git a/relay-spans/src/v1_to_v2.rs b/relay-spans/src/v1_to_v2.rs index 39a82e9ed89..e1c41c75c52 100644 --- a/relay-spans/src/v1_to_v2.rs +++ b/relay-spans/src/v1_to_v2.rs @@ -38,7 +38,7 @@ pub fn span_v1_to_span_v2(span_v1: SpanV1) -> SpanV2 { platform, was_transaction, kind, - performance_issues_spans, + performance_issues_spans: _, // moved to SpanMeta on the Kafka envelope other: _, } = span_v1; @@ -55,10 +55,6 @@ pub fn span_v1_to_span_v2(span_v1: SpanV1) -> SpanV2 { attributes.insert("sentry.profile_id", profile_id.map_value(|v| v.to_string())); attributes.insert("sentry.platform", platform); attributes.insert("sentry.was_transaction", was_transaction); - attributes.insert( - "sentry._internal.performance_issues_spans", - performance_issues_spans, - ); // Use same precedence as `backfill_data` for data bags: if let Some(measurements) = measurements.into_value() { @@ -371,10 +367,6 @@ mod tests { "type": "string", "value": "{\"numbers\":[1,2,3]}" }, - "sentry._internal.performance_issues_spans": { - "type": "boolean", - "value": true - }, "sentry.client_sample_rate": { "type": "double", "value": 0.11 diff --git a/tests/integration/test_spans.py b/tests/integration/test_spans.py index 9048e5c0906..0eabc9ac8cf 100644 --- a/tests/integration/test_spans.py +++ b/tests/integration/test_spans.py @@ -196,12 +196,7 @@ def test_span_extraction( del transaction_span["received"] if performance_issues_spans: - assert ( - transaction_span["attributes"].pop( - "sentry._internal.performance_issues_spans" - )["value"] - is True - ) + assert transaction_span.pop("_performance_issues_spans") is True expected_transaction_span = { "attributes": {