Skip to content

Commit d7349e2

Browse files
authored
inc: Add killswitch for trace id partitioning (#4706)
ref INC-1143 Some projects send such heavy abuse into single trace IDs that this causes problems in production today. A better solution is needed long-term as disabling this partition will lead to product degradation once span buffer is rolled out. Why a global option instead of a projectconfig? I think global options are easier to reason about wrt how they propagate, and it's easier to globally disable trace id partitioning this way.
1 parent 592bd5d commit d7349e2

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Add OTA Updates Event Context for Expo and other applications. ([#4690](https://github.com/getsentry/relay/pull/4690))
1010
- Add data categories for Seer. ([#4692](https://github.com/getsentry/relay/pull/4692))
1111
- Allow pii scrubbing of all span `sentry_tags` fields. ([#4698](https://github.com/getsentry/relay/pull/4698))
12+
- Add killswitch for trace id partitioning. ([#4706](https://github.com/getsentry/relay/pull/4706))
1213

1314
**Bug Fixes**:
1415

relay-dynamic-config/src/global.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ pub struct Options {
225225
)]
226226
pub deprecated2: f32,
227227

228+
/// Disable semantic partitioning of spans by trace ID. Use this in case there is partition
229+
/// imbalance on the spans topic produced to by Relay (either snuba-spans or ingest-spans).
230+
/// This will break the span buffer, and anything that depends on segments being assembled by
231+
/// it (performance issue, etc). As of 2025-05-06, the span buffer is not yet rolled out to
232+
/// most regions though.
233+
#[serde(
234+
rename = "relay.spans-ignore-trace-id-partitioning.projects",
235+
skip_serializing_if = "is_default"
236+
)]
237+
pub spans_ignore_trace_id_partitioning: bool,
238+
228239
/// All other unknown options.
229240
#[serde(flatten)]
230241
other: HashMap<String, Value>,

relay-server/src/services/store.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,20 @@ impl StoreService {
506506
&self,
507507
topic: KafkaTopic,
508508
// Takes message by value to ensure it is not being produced twice.
509-
message: KafkaMessage,
509+
mut message: KafkaMessage,
510510
) -> Result<(), StoreError> {
511511
relay_log::trace!("Sending kafka message of type {}", message.variant());
512512

513+
if let KafkaMessage::Span {
514+
ref mut ignore_trace_id_partitioning,
515+
..
516+
} = message
517+
{
518+
let global_config = self.global_config.current();
519+
*ignore_trace_id_partitioning =
520+
global_config.options.spans_ignore_trace_id_partitioning;
521+
}
522+
513523
let topic_name = self.producer.client.send_message(topic, &message)?;
514524

515525
match &message {
@@ -932,6 +942,7 @@ impl StoreService {
932942
scoping.project_id.to_string(),
933943
)]),
934944
message: span,
945+
ignore_trace_id_partitioning: false,
935946
},
936947
)?;
937948

@@ -1588,6 +1599,8 @@ enum KafkaMessage<'a> {
15881599
headers: BTreeMap<String, String>,
15891600
#[serde(flatten)]
15901601
message: SpanKafkaMessage<'a>,
1602+
#[serde(skip)]
1603+
ignore_trace_id_partitioning: bool,
15911604
},
15921605
Log {
15931606
#[serde(skip)]
@@ -1631,7 +1644,17 @@ impl Message for KafkaMessage<'_> {
16311644
Self::AttachmentChunk(message) => message.event_id.0,
16321645
Self::UserReport(message) => message.event_id.0,
16331646
Self::ReplayEvent(message) => message.replay_id.0,
1634-
Self::Span { message, .. } => message.trace_id.0,
1647+
Self::Span {
1648+
message,
1649+
ignore_trace_id_partitioning,
1650+
..
1651+
} => {
1652+
if *ignore_trace_id_partitioning {
1653+
Uuid::nil()
1654+
} else {
1655+
message.trace_id.0
1656+
}
1657+
}
16351658

16361659
// Monitor check-ins use the hinted UUID passed through from the Envelope.
16371660
//

0 commit comments

Comments
 (0)