Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Make sure op/name/description are set correctly on transactions/spans #3519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 3 sentry_sdk/integrations/opentelemetry/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ def extract_span_data(span):
if span.attributes is None:
return (op, description, status, http_status, origin)

origin = span.attributes.get(SentrySpanAttribute.ORIGIN)
op = span.attributes.get(SentrySpanAttribute.OP) or op
description = span.attributes.get(SentrySpanAttribute.DESCRIPTION) or description
origin = span.attributes.get(SentrySpanAttribute.ORIGIN)

http_method = span.attributes.get(SpanAttributes.HTTP_METHOD)
http_method = cast("Optional[str]", http_method)
Expand Down
2 changes: 1 addition & 1 deletion 2 sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ def __init__(
start_timestamp = convert_to_otel_timestamp(start_timestamp)

self._otel_span = tracer.start_span(
description or op or "", start_time=start_timestamp
name or description or op or "", start_time=start_timestamp
antonpirker marked this conversation as resolved.
Show resolved Hide resolved
)

self.origin = origin or DEFAULT_SPAN_ORIGIN
Expand Down
56 changes: 56 additions & 0 deletions 56 tests/integrations/opentelemetry/test_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import sentry_sdk


def test_transaction_name_span_description_compat(
sentry_init,
capture_events,
):
sentry_init(traces_sample_rate=1.0)

events = capture_events()

with sentry_sdk.start_transaction(
name="trx-name",
op="trx-op",
) as trx:
with sentry_sdk.start_span(
description="span-desc",
op="span-op",
) as spn:
...

assert trx.__class__.__name__ == "POTelSpan"
assert trx.op == "trx-op"
assert trx.name == "trx-name"
assert trx.description is None

assert trx._otel_span is not None
assert trx._otel_span.name == "trx-name"
assert trx._otel_span.attributes["sentry.op"] == "trx-op"
assert trx._otel_span.attributes["sentry.name"] == "trx-name"
assert "sentry.description" not in trx._otel_span.attributes

assert spn.__class__.__name__ == "POTelSpan"
assert spn.op == "span-op"
assert spn.description == "span-desc"
assert spn.name is None

assert spn._otel_span is not None
assert spn._otel_span.name == "span-desc"
assert spn._otel_span.attributes["sentry.op"] == "span-op"
assert spn._otel_span.attributes["sentry.description"] == "span-desc"
assert "sentry.name" not in spn._otel_span.attributes

transaction = events[0]
assert transaction["transaction"] == "trx-name"
assert transaction["contexts"]["trace"]["op"] == "trx-op"
assert transaction["contexts"]["trace"]["data"]["sentry.op"] == "trx-op"
assert transaction["contexts"]["trace"]["data"]["sentry.name"] == "trx-name"
assert "sentry.description" not in transaction["contexts"]["trace"]["data"]

span = transaction["spans"][0]
assert span["description"] == "span-desc"
assert span["op"] == "span-op"
assert span["data"]["sentry.op"] == "span-op"
assert span["data"]["sentry.description"] == "span-desc"
assert "sentry.name" not in span["data"]
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.