Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Make `_performance_issues_spans` a top-level field. ([#5870](https://github.com/getsentry/relay/pull/5870))
- Make `_performance_issues_spans` a top-level field on the Kafka message. ([#5870](https://github.com/getsentry/relay/pull/5870))


**Bug Fixes**:

Expand Down
6 changes: 6 additions & 0 deletions relay-server/src/processing/legacy_spans/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ macro_rules! required {

/// Converts a [`Span`] into a [`StoreSpanV2`] to be sent to Kafka.
pub fn convert(span: Annotated<Span>, retentions: Retention) -> Result<Box<StoreSpanV2>> {
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);

Ok(Box::new(StoreSpanV2 {
routing_key: span.trace_id.value().copied().map(Into::into),
retention_days: retentions.standard,
downsampled_retention_days: retentions.downsampled,
performance_issues_spans,
item: span,
}))
}
1 change: 1 addition & 0 deletions relay-server/src/processing/spans/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn convert(span: IndexedSpanOnly, ctx: &Context) -> Result<Box<StoreSpanV2>>
routing_key,
retention_days: ctx.retention.standard,
downsampled_retention_days: ctx.retention.downsampled,
performance_issues_spans: false,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
performance_issues_spans: false,
performance_issues_spans: false, // only used for legacy spans

item: span,
}))
}
Expand Down
16 changes: 16 additions & 0 deletions relay-server/src/services/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +141 to +142
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
///
/// 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,
}
Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -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.
Comment on lines +1687 to +1688
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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.
/// When the flag is set to true, performance issues will be detected on this span
/// instead of the transaction event (provided it is a segment span).

///
/// 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)]
Expand Down
10 changes: 1 addition & 9 deletions relay-spans/src/v1_to_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
performance_issues_spans: _, // moved to SpanMeta on the Kafka envelope
performance_issues_spans: _, // not part of the V2 protocol (but still used by `legacy_spans::store::convert`).

other: _,
} = span_v1;

Expand All @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions tests/integration/test_spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Loading