ref: Support outgoing trace propagation in span first (18)#5638
ref: Support outgoing trace propagation in span first (18)#5638sentrivana wants to merge 5 commits intoivana/span-first-17-missing-data-categoryfrom
Conversation
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
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)
Generated by Codecov Action |
| self._span.containing_transaction.source = source | ||
| if self._span: | ||
| if isinstance(self._span, NoOpStreamedSpan): | ||
| return |
There was a problem hiding this comment.
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
| return | |
| pass | |
| if isinstance(self._span, StreamedSpan) and not isinstance(self._span, NoOpStreamedSpan): |
Identified by Warden code-review · HK5-6C8
Couple things going on in this PR:
_get_traceparent,_get_baggage,_iter_headers, etc. These mirror the oldSpanclass to make integratingStreamedSpans with the rest of the SDK easier (since they're used throughout), with one difference: they're explicitly private, while the correspondingSpanmethods were public. Added aliases to them so that we can use the private methods everywhere.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)