-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tracing): Only propagate headers from spans within transactions
This change ensures that we only propagate trace headers from spans that are within a transaction. This fixes a bug where any child transactions of a span created outside a transaction are missing a dynamic sampling context and are part of a trace missing a root transaction (because the root is the span). Also, remove/modify tests that were asserting the old behavior. Fixes #3068
- Loading branch information
1 parent
a02eb9c
commit 94a6c2a
Showing
5 changed files
with
78 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import sentry_sdk | ||
import pytest | ||
|
||
|
||
def test_standalone_span_iter_headers(sentry_init): | ||
sentry_init(enable_tracing=True) | ||
|
||
with sentry_sdk.start_span(op="test") as span: | ||
with pytest.raises(StopIteration): | ||
# We should not have any propagation headers | ||
next(span.iter_headers()) | ||
|
||
|
||
def test_span_in_span_iter_headers(sentry_init): | ||
sentry_init(enable_tracing=True) | ||
|
||
with sentry_sdk.start_span(op="test"): | ||
with sentry_sdk.start_span(op="test2") as span_inner: | ||
with pytest.raises(StopIteration): | ||
# We should not have any propagation headers | ||
next(span_inner.iter_headers()) | ||
|
||
|
||
def test_span_in_transaction(sentry_init): | ||
sentry_init(enable_tracing=True) | ||
|
||
with sentry_sdk.start_transaction(op="test"): | ||
with sentry_sdk.start_span(op="test2") as span: | ||
# Ensure the headers are there | ||
next(span.iter_headers()) | ||
|
||
|
||
def test_span_in_span_in_transaction(sentry_init): | ||
sentry_init(enable_tracing=True) | ||
|
||
with sentry_sdk.start_transaction(op="test"): | ||
with sentry_sdk.start_span(op="test2"): | ||
with sentry_sdk.start_span(op="test3") as span_inner: | ||
# Ensure the headers are there | ||
next(span_inner.iter_headers()) |