Skip to content

Commit 44f4862

Browse files
committed
tests
1 parent 43b8e40 commit 44f4862

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

sentry_sdk/traces.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,17 +580,23 @@ def _set_segment_attributes(self) -> None:
580580
SPANDATA.SENTRY_SDK_INTEGRATIONS, sorted(client.integrations.keys())
581581
)
582582

583-
if client.options.get("release"):
583+
if (
584+
client.options.get("release")
585+
and SPANDATA.SENTRY_RELEASE not in self._attributes
586+
):
584587
self.set_attribute(
585588
SPANDATA.SENTRY_RELEASE, client.options["release"].strip()
586589
)
587590

588-
if client.options.get("environment"):
591+
if (
592+
client.options.get("environment")
593+
and SPANDATA.SENTRY_ENVIRONMENT not in self._attributes
594+
):
589595
self.set_attribute(
590596
SPANDATA.SENTRY_ENVIRONMENT, client.options["environment"].strip()
591597
)
592598

593-
if client.options.get("dist"):
599+
if client.options.get("dist") and SPANDATA.SENTRY_DIST not in self._attributes:
594600
self.set_attribute(SPANDATA.SENTRY_DIST, client.options["dist"].strip())
595601

596602
def _to_json(self) -> "SpanJSON":

tests/tracing/test_span_streaming.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,7 @@ def test_default_attributes(sentry_init, capture_envelopes):
16221622
sentry_init(
16231623
server_name="test-server",
16241624
release="1.0.0",
1625+
dist="1.0",
16251626
traces_sample_rate=1.0,
16261627
_experiments={"trace_lifecycle": "stream"},
16271628
)
@@ -1653,6 +1654,9 @@ def test_default_attributes(sentry_init, capture_envelopes):
16531654
"sentry.sdk.version": {"value": mock.ANY, "type": "string"},
16541655
"server.address": {"value": "test-server", "type": "string"},
16551656
"sentry.environment": {"value": "production", "type": "string"},
1657+
"sentry.platform": {"value": "python", "type": "string"},
16561658
"sentry.release": {"value": "1.0.0", "type": "string"},
1659+
"sentry.dist": {"value": "1.0", "type": "string"},
16571660
"sentry.origin": {"value": "manual", "type": "string"},
1661+
"sentry.sdk.integrations": {"value": mock.ANY, "type": "array"},
16581662
}

0 commit comments

Comments
 (0)