-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
name
parameter to start_span()
and deprecated description
…
… parameter. (#3524) To align our API with OpenTelementry. In OTel a span has no description but a name. This only changes to user facing API, under the hood there is still everything using the description. (This will then be changed with OTel)
- Loading branch information
1 parent
a581542
commit b1b16b0
Showing
4 changed files
with
85 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import pytest | ||
|
||
import sentry_sdk | ||
|
||
|
||
def test_start_span_description(sentry_init, capture_events): | ||
sentry_init(traces_sample_rate=1.0) | ||
events = capture_events() | ||
|
||
with sentry_sdk.start_transaction(name="hi"): | ||
with pytest.deprecated_call(): | ||
with sentry_sdk.start_span(op="foo", description="span-desc"): | ||
... | ||
|
||
(event,) = events | ||
|
||
assert event["spans"][0]["description"] == "span-desc" | ||
|
||
|
||
def test_start_span_name(sentry_init, capture_events): | ||
sentry_init(traces_sample_rate=1.0) | ||
events = capture_events() | ||
|
||
with sentry_sdk.start_transaction(name="hi"): | ||
with sentry_sdk.start_span(op="foo", name="span-name"): | ||
... | ||
|
||
(event,) = events | ||
|
||
assert event["spans"][0]["description"] == "span-name" | ||
|
||
|
||
def test_start_child_description(sentry_init, capture_events): | ||
sentry_init(traces_sample_rate=1.0) | ||
events = capture_events() | ||
|
||
with sentry_sdk.start_transaction(name="hi"): | ||
with pytest.deprecated_call(): | ||
with sentry_sdk.start_span(op="foo", description="span-desc") as span: | ||
with span.start_child(op="bar", description="child-desc"): | ||
... | ||
|
||
(event,) = events | ||
|
||
assert event["spans"][-1]["description"] == "child-desc" | ||
|
||
|
||
def test_start_child_name(sentry_init, capture_events): | ||
sentry_init(traces_sample_rate=1.0) | ||
events = capture_events() | ||
|
||
with sentry_sdk.start_transaction(name="hi"): | ||
with sentry_sdk.start_span(op="foo", name="span-name") as span: | ||
with span.start_child(op="bar", name="child-name"): | ||
... | ||
|
||
(event,) = events | ||
|
||
assert event["spans"][-1]["description"] == "child-name" |