-
Notifications
You must be signed in to change notification settings - Fork 117
chore(contexts): Remove default-trace-ID option #5979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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<Contexts>, | ||
| 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<Contexts>, 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::<TraceContext>() { | ||
| if !contexts.contains::<TraceContext>() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can unify the branches with |
||
| contexts.add(TraceContext::random(event_id)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there's a |
||
| } else { | ||
| let trace_ctx = contexts.get_or_default::<TraceContext>(); | ||
| if trace_ctx.trace_id.0.is_none() { | ||
| trace_ctx.trace_id = Annotated::new(TraceId::random()) | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent trace ID derivation between if/else branchesMedium Severity When no Reviewed by Cursor Bugbot for commit 9942b0b. Configure here. |
||
| } | ||
|
|
||
| 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() | ||
| }, | ||
| ); | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.