Skip to content

ref: Support outgoing trace propagation in span first (18)#5638

Draft
sentrivana wants to merge 5 commits intoivana/span-first-17-missing-data-categoryfrom
ivana/span-first-18-trace-propagation
Draft

ref: Support outgoing trace propagation in span first (18)#5638
sentrivana wants to merge 5 commits intoivana/span-first-17-missing-data-categoryfrom
ivana/span-first-18-trace-propagation

Conversation

@sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Mar 11, 2026

Couple things going on in this PR:

  1. Support getting trace propagation information from the span with _get_traceparent, _get_baggage, _iter_headers, etc. These mirror the old Span class to make integrating StreamedSpans with the rest of the SDK easier (since they're used throughout), with one difference: they're explicitly private, while the corresponding Span methods were public. Added aliases to them so that we can use the private methods everywhere.
  • There is definite clean up potential here once we get rid of the old spans and we no longer have to make the streaming span interface work with the existing helper scope methods.
  1. In terms of type checking, now that we're officially allowing StreamedSpans to be set on the scope, a LOT of type hints need updating. In many places, I've added explicit guards against functionality that doesn't exist in span first mode. This should prevent folks from using the wrong APIs in the wrong SDK mode (tracing vs. static) as well as make mypy happy.

TODOs:
[ ] fix the rest of the things mypy's complaining about
[x] fix tests
[x] make sure trace propagation works as expected when a no-op span is active (add a test, too)

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

Codecov Results 📊

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

All tests are passing successfully.

❌ Patch coverage is 29.41%. Project has 14134 uncovered lines.

Files with missing lines (7)
File Patch % Lines
tracing_utils.py 37.72% ⚠️ 459 Missing and 28 partials
scope.py 67.43% ⚠️ 283 Missing and 69 partials
traces.py 36.39% ⚠️ 187 Missing
tracing.py 72.02% ⚠️ 136 Missing and 38 partials
api.py 63.52% ⚠️ 58 Missing
_span_batcher.py 31.94% ⚠️ 49 Missing
feature_flags.py 57.58% ⚠️ 14 Missing

Generated by Codecov Action

@sentrivana sentrivana changed the title ref: Support outgoing trace propagation in span first ref: Support outgoing trace propagation in span first (18) Mar 11, 2026
self._span.containing_transaction.source = source
if self._span:
if isinstance(self._span, NoOpStreamedSpan):
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Early return in set_transaction_name skips transaction_info source storage

When self._span is a NoOpStreamedSpan, the method returns early on line 843, which skips the self._transaction_info["source"] = source assignment on line 858. In the old code, the source was always stored in _transaction_info regardless of the span type. This behavioral change could affect event processing that relies on _transaction_info["source"] being set.

Verification

Read the original code from the diff which showed if source: self._transaction_info["source"] = source was unconditionally executed after the span-handling logic. The new code has return on line 843 for NoOpStreamedSpan which prevents reaching line 858.

Suggested fix: Move the return after the source storage, or remove the early return and just skip the span updates

Suggested change
return
pass
if isinstance(self._span, StreamedSpan) and not isinstance(self._span, NoOpStreamedSpan):

Identified by Warden code-review · HK5-6C8

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.

1 participant