Skip to content

feat(transaction): Propagate segment_name to spans#5959

Closed
loewenheim wants to merge 6 commits intomasterfrom
sebastian/transaction-segment-name
Closed

feat(transaction): Propagate segment_name to spans#5959
loewenheim wants to merge 6 commits intomasterfrom
sebastian/transaction-segment-name

Conversation

@loewenheim
Copy link
Copy Markdown
Contributor

This propagates an event's transaction field to the event's spans as data.segment_name. Previously, we were only doing this when converting a transaction into a span, which meant that only the root span had this field set.

This propagates an event's `transaction` field to the event's spans as
`data.segment_name`. Previously, we were only doing this when converting
a transaction into a span, which meant that only the root span had this
field set.
@loewenheim loewenheim requested a review from a team as a code owner May 7, 2026 14:09
Comment thread relay-event-normalization/src/normalize/span/tag_extraction.rs Outdated
Comment thread relay-event-normalization/src/event.rs Outdated
@Dav1dde Dav1dde requested a review from mjq May 7, 2026 14:46
@Dav1dde
Copy link
Copy Markdown
Member

Dav1dde commented May 7, 2026

@mjq wdyt is that a bug or does the product require this/should it be in the segment processor/enricher?

Edit: @gggritso 👀 I heard matt is on vacation and you're the replacement we can bother

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a48d977. Configure here.

Comment thread relay-event-normalization/src/normalize/span/tag_extraction.rs Outdated
Comment on lines +80 to +82
if data.segment_name.is_empty() {
data.segment_name = Annotated::new(transaction.clone());
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The check data.segment_name.is_empty() is incorrect for an Annotated type, as it can return false if metadata exists, even when the value itself is None.
Severity: LOW

Suggested Fix

To correctly check for a missing value in an Annotated field, regardless of its metadata, change the condition from data.segment_name.is_empty() to data.segment_name.value().is_none(). This ensures the check is performed on the value itself.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: relay-event-normalization/src/normalize/span/tag_extraction.rs#L80-L82

Potential issue: The code uses `data.segment_name.is_empty()` to check if a child span's
segment name is missing. However, for an `Annotated<T>` type, `is_empty()` returns
`false` if metadata is present, even if the underlying value is `None`. This scenario
occurs if an SDK sends a malformed `segment_name` (e.g., an integer), which results in a
`None` value but with validation error metadata. Consequently, the check incorrectly
evaluates to `false`, and the code fails to populate the `segment_name` from the parent
transaction's name as intended.

Did we get this right? 👍 / 👎 to inform future reviews.

@loewenheim
Copy link
Copy Markdown
Contributor Author

Per discussion on Slack, this is the wrong approach: Filling the child spans' sentry.segment.name attributes doesn't help because the segment enricher will later overwrite it based on the segment span's name. As such, I'm closing this in favor of #5961.

@loewenheim loewenheim closed this May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants