Skip to content

fix(metrics,logs): Don't attach span_id if no active span#6162

Merged
sentrivana merged 10 commits intomasterfrom
ivana/dont-attach-trace-id-if-not-known
Apr 30, 2026
Merged

fix(metrics,logs): Don't attach span_id if no active span#6162
sentrivana merged 10 commits intomasterfrom
ivana/dont-attach-trace-id-if-not-known

Conversation

@sentrivana
Copy link
Copy Markdown
Contributor

Description

Per the log/metrics spec, we shouldn't attach a span ID unless there's an active span. In the current implementation, due to how the propagation context works, we'd synthesize a span ID in this case.

Circumvent that code path by directly checking for an active span.

Issues

Reminders

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 28, 2026

@sentrivana sentrivana changed the title fix(metrics): Don't attach a span_id if there is no active span fix(metrics,logs): Don't attach a span_id if there is no active span Apr 28, 2026
@sentrivana sentrivana changed the title fix(metrics,logs): Don't attach a span_id if there is no active span fix(metrics,logs): Don't attach span_id if no active span Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 8.01s

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 14873 uncovered lines.

Files with missing lines (1)
File Patch % Lines
scope.py 71.38% ⚠️ 251 Missing and 82 partials

Generated by Codecov Action

Comment thread sentry_sdk/scope.py Outdated
Comment thread sentry_sdk/scope.py Outdated
@sentrivana sentrivana marked this pull request as ready for review April 28, 2026 13:11
@sentrivana sentrivana requested a review from a team as a code owner April 28, 2026 13:11
Comment thread sentry_sdk/scope.py Outdated
Comment thread sentry_sdk/scope.py Outdated
Copy link
Copy Markdown
Member

@ericapisani ericapisani left a comment

Choose a reason for hiding this comment

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

Other than the notes from Cursor, this LGTM. Approving so as not to block

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 a98293d. Configure here.

Comment thread sentry_sdk/scope.py Outdated
@sentrivana sentrivana merged commit fc3eab4 into master Apr 30, 2026
155 of 156 checks passed
@sentrivana sentrivana deleted the ivana/dont-attach-trace-id-if-not-known branch April 30, 2026 07:11
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.

Align metric span_id attachment with the metrics spec

2 participants