Skip to content

fix(scopes): don't drop propagation context when event already has contexts#1843

Merged
limbonaut merged 3 commits into
masterfrom
limbonaut/fix/trace-missing-in-local-scope
Jul 7, 2026
Merged

fix(scopes): don't drop propagation context when event already has contexts#1843
limbonaut merged 3 commits into
masterfrom
limbonaut/fix/trace-missing-in-local-scope

Conversation

@limbonaut

@limbonaut limbonaut commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

When a scope is applied to an event, the trace context created by sentry_set_trace() was only added if the event had no existing contexts. This creates a problem when a local scope is applied before the global scope, because it adds contexts to event and the trace infomation is skipped so the event loses its trace id. This PR fixes this by ensuring the propagation context is applied whenever an event doesn't already have a trace or active span. Also, adding tests to verify correct behavior.

@limbonaut limbonaut marked this pull request as ready for review July 6, 2026 19:00
Comment thread src/sentry_scope.c
}
PLACE_VALUE("contexts", contexts);
} else {
sentry__value_merge_objects(event_contexts, contexts);

@limbonaut limbonaut Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Notice that the else branch skips adding propagation context altogether. So, just having pre-existing contexts omits adding trace completely.

@limbonaut limbonaut changed the title WIP: fix(scopes): don't drop propagation context when event already has contexts fix(scopes): don't drop propagation context when event already has contexts Jul 6, 2026
@limbonaut limbonaut merged commit 4c958b7 into master Jul 7, 2026
66 checks passed
@limbonaut limbonaut deleted the limbonaut/fix/trace-missing-in-local-scope branch July 7, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants