From 9942b0bb7c15faae1bc3e59de578b7d35cbb152c Mon Sep 17 00:00:00 2001 From: Charles Paul Date: Tue, 12 May 2026 12:38:45 -0700 Subject: [PATCH] chore(contexts): Remove default-trace-ID option --- CHANGELOG.md | 1 + relay-cabi/src/processing.rs | 1 - relay-dynamic-config/src/feature.rs | 3 --- relay-event-normalization/src/event.rs | 28 +++++++++------------- relay-server/src/processing/utils/event.rs | 1 - 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 378c8c7deb0..0e448452658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Enable compression for forwarded uploads. ([#5965](https://github.com/getsentry/relay/pull/5965)) - Change the default partitioning for the envelope buffer from semantic to round-robin. ([#5967](https://github.com/getsentry/relay/pull/5967)) - Enable retries for upload requests to upstream. ([#5975](https://github.com/getsentry/relay/pull/5975)) +- Unconditionally create a trace context with a trace id for errors. ([#5979](https://github.com/getsentry/relay/pull/5979)) ## 26.4.2 diff --git a/relay-cabi/src/processing.rs b/relay-cabi/src/processing.rs index 94bdb65f6ce..43d443fadcd 100644 --- a/relay-cabi/src/processing.rs +++ b/relay-cabi/src/processing.rs @@ -274,7 +274,6 @@ pub unsafe extern "C" fn relay_store_normalizer_normalize_event( span_allowed_hosts: &[], // only supported in relay span_op_defaults: Default::default(), // only supported in relay performance_issues_spans: Default::default(), - derive_trace_id: Default::default(), }; normalize_event(&mut event, &normalization_config); diff --git a/relay-dynamic-config/src/feature.rs b/relay-dynamic-config/src/feature.rs index 6febf8f625e..15b86392c6e 100644 --- a/relay-dynamic-config/src/feature.rs +++ b/relay-dynamic-config/src/feature.rs @@ -95,9 +95,6 @@ pub enum Feature { /// Upload non-prosperodmp playstation attachments via the upload endpoint. #[serde(rename = "projects:relay-playstation-uploads")] PlaystationUploads, - /// Add a random trace ID to events that lack one. - #[serde(rename = "organizations:relay-default-trace-id")] - AddDefaultTraceID, /// Enable experimental expansion of the unreal report in the endpoint rather than in the /// processor. Only enable for organizations with sufficient attachment quota. #[serde(rename = "organizations:relay-unreal-endpoint-expansion")] diff --git a/relay-event-normalization/src/event.rs b/relay-event-normalization/src/event.rs index 731f270476c..a3663d556dd 100644 --- a/relay-event-normalization/src/event.rs +++ b/relay-event-normalization/src/event.rs @@ -23,7 +23,7 @@ use relay_event_schema::protocol::{ AsPair, Attributes, AutoInferSetting, ClientSdkInfo, Context, ContextInner, Contexts, DebugImage, DeviceClass, Event, EventId, EventType, Exception, Headers, IpAddr, Level, LogEntry, Measurement, Measurements, PerformanceScoreContext, ReplayContext, Request, Span, - SpanStatus, SpanV2, Tags, Timestamp, TraceContext, User, VALID_PLATFORMS, + SpanStatus, SpanV2, Tags, Timestamp, TraceContext, TraceId, User, VALID_PLATFORMS, }; use relay_protocol::{ Annotated, Empty, Error, ErrorKind, FiniteF64, FromValue, Getter, Meta, Object, Remark, @@ -168,9 +168,6 @@ pub struct NormalizationConfig<'a> { /// Set a flag to enable performance issue detection on spans. pub performance_issues_spans: bool, - - /// Should add a random trace ID to events that lack one. - pub derive_trace_id: bool, } impl Default for NormalizationConfig<'_> { @@ -205,7 +202,6 @@ impl Default for NormalizationConfig<'_> { span_allowed_hosts: Default::default(), span_op_defaults: Default::default(), performance_issues_spans: Default::default(), - derive_trace_id: Default::default(), } } } @@ -334,7 +330,7 @@ fn normalize(event: &mut Event, meta: &mut Meta, config: &NormalizationConfig) { let event_id = event.id.value().unwrap().0; // Some contexts need to be normalized before metrics extraction takes place. - normalize_contexts(&mut event.contexts, event_id, config); + normalize_contexts(&mut event.contexts, event_id); if config.normalize_spans && event.ty.value() == Some(&EventType::Transaction) { crate::normalize::normalize_app_start_spans(event); @@ -1355,15 +1351,9 @@ fn remove_logger_word(tokens: &mut Vec<&str>) { } /// Normalizes incoming contexts for the downstream metric extraction. -fn normalize_contexts( - contexts: &mut Annotated, - event_id: Uuid, - config: &NormalizationConfig, -) { - if config.derive_trace_id { - // We will always need a TraceContext. - let _ = contexts.get_or_insert_with(Contexts::new); - } +fn normalize_contexts(contexts: &mut Annotated, event_id: Uuid) { + // We will always need a TraceContext. + let _ = contexts.get_or_insert_with(Contexts::new); let _ = processor::apply(contexts, |contexts, _meta| { // Reprocessing context sent from SDKs must not be accepted, it is a Sentry-internal @@ -1374,8 +1364,13 @@ fn normalize_contexts( // We need a TraceId to ingest the event into EAP. // If the event lacks a TraceContext, add a random one. - if config.derive_trace_id && !contexts.contains::() { + if !contexts.contains::() { contexts.add(TraceContext::random(event_id)) + } else { + let trace_ctx = contexts.get_or_default::(); + if trace_ctx.trace_id.0.is_none() { + trace_ctx.trace_id = Annotated::new(TraceId::random()) + } } for annotated in &mut contexts.0.values_mut() { @@ -4958,7 +4953,6 @@ mod tests { &mut Meta::default(), &NormalizationConfig { performance_score: Some(&performance_score), - derive_trace_id: true, ..Default::default() }, ); diff --git a/relay-server/src/processing/utils/event.rs b/relay-server/src/processing/utils/event.rs index 7c2e63a0ab1..455285dc1ae 100644 --- a/relay-server/src/processing/utils/event.rs +++ b/relay-server/src/processing/utils/event.rs @@ -301,7 +301,6 @@ pub fn normalize( performance_issues_spans: ctx .project_info .has_feature(Feature::PerformanceIssuesSpans), - derive_trace_id: project_info.has_feature(Feature::AddDefaultTraceID), }; metric!(timer(RelayTimers::EventProcessingNormalization), {