-
Notifications
You must be signed in to change notification settings - Fork 121
ref(spans): Modify segment attributes during conversion #6126
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
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 |
|---|---|---|
|
|
@@ -167,7 +167,12 @@ fn expand_legacy_span(item: &Item) -> Result<WithHeader<SpanV2>> { | |
| // We can't enable `infer_name` here: | ||
| // These spans haven't been PII scrubbed yet, so inferring a name would risk | ||
| // leaking PII. | ||
| .map_value(|span| relay_spans::span_v1_to_span_v2(span, false)); | ||
| .map_value(|mut span| { | ||
| // Set some segment-related attributes before converting to V2. | ||
| // This exists for parity with the legacy standalone span pipeline. | ||
| relay_spans::set_segment_attributes(&mut span); | ||
| relay_spans::span_v1_to_span_v2(span, false) | ||
| }); | ||
|
Comment on lines
+171
to
+175
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. Bug: For legacy web vital spans, Suggested FixExplicitly remove the Prompt for AI AgentAlso affects:
|
||
|
|
||
| Ok(WithHeader::new(span)) | ||
| } | ||
|
|
@@ -234,7 +239,6 @@ fn normalize_span( | |
| // because category derivation depends on having the sentry.op attribute | ||
| // available. | ||
| eap::normalize_sentry_op(&mut span.attributes); | ||
| eap::normalize_web_vital_span_segment(span); | ||
|
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. Native V2 web vital segmentsMedium Severity Removing Reviewed by Cursor Bugbot for commit 3e2bd9a. Configure here.
Contributor
Author
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. This is intentional. In V2 we simply require that SDKs set the |
||
| eap::normalize_span_category(&mut span.attributes); | ||
|
sentry[bot] marked this conversation as resolved.
|
||
| eap::normalize_received(&mut span.attributes, meta.received_at()); | ||
| eap::normalize_client_address(&mut span.attributes, meta.client_addr()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| use relay_event_schema::protocol::Span; | ||
| use relay_protocol::Empty; | ||
|
|
||
| /// Normalizes various segment-related fields on a span: | ||
| /// | ||
| /// * Web vital spans have `is_segment`, `parent_span_id`, and `segment_id` erased. | ||
| /// * Spans whose `span_id` is equal to the `segment_id` or which don't have a `parent_span_id` have | ||
| /// `is_segment` set to `true`. | ||
| /// * Finally, segment spans have the `segment_id` set to their own `span_id`. | ||
| pub fn set_segment_attributes(span: &mut Span) { | ||
| // Identify INP spans or other WebVital spans and make sure they are not wrapped in a segment. | ||
| if let Some(span_op) = span.op.value() | ||
| && (span_op.starts_with("ui.interaction.") || span_op.starts_with("ui.webvital.")) | ||
| { | ||
| span.is_segment = None.into(); | ||
| span.parent_span_id = None.into(); | ||
| span.segment_id = None.into(); | ||
| return; | ||
| } | ||
|
|
||
| let Some(span_id) = span.span_id.value() else { | ||
| return; | ||
| }; | ||
|
|
||
| if let Some(segment_id) = span.segment_id.value() { | ||
| // The span is a segment if and only if the segment_id matches the span_id. | ||
| span.is_segment = (segment_id == span_id).into(); | ||
| } else if span.parent_span_id.is_empty() { | ||
| // If the span has no parent, it is automatically a segment: | ||
| span.is_segment = true.into(); | ||
| } | ||
|
|
||
| // If the span is a segment, always set the segment_id to the current span_id: | ||
| if span.is_segment.value() == Some(&true) { | ||
| span.segment_id = span.span_id.clone(); | ||
| } | ||
|
Comment on lines
+25
to
+36
Contributor
Author
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. These normalizations would previously happen in the legacy standalone span pipeline, but not the V2 one. |
||
| } | ||


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