Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
SHARED_SENTRY_ATTRIBUTES = (
ATTRIBUTE_NAMES.SENTRY_RELEASE,
ATTRIBUTE_NAMES.SENTRY_ENVIRONMENT,
ATTRIBUTE_NAMES.SENTRY_TRANSACTION,
ATTRIBUTE_NAMES.SENTRY_SEGMENT_NAME,
"sentry.transaction.method",
"sentry.transaction.op",
"sentry.trace.status",
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/spans/consumers/process_segments/shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def build_shim_event_data(
},
"event_id": uuid.uuid4().hex,
"project_id": segment_span["project_id"],
"transaction": attribute_value(segment_span, ATTRIBUTE_NAMES.SENTRY_TRANSACTION),
"transaction": attribute_value(segment_span, ATTRIBUTE_NAMES.SENTRY_SEGMENT_NAME),
"release": attribute_value(segment_span, ATTRIBUTE_NAMES.SENTRY_RELEASE),
"dist": attribute_value(segment_span, ATTRIBUTE_NAMES.SENTRY_DIST),
"environment": attribute_value(segment_span, ATTRIBUTE_NAMES.SENTRY_ENVIRONMENT),
Expand Down
18 changes: 11 additions & 7 deletions tests/sentry/spans/consumers/process_segments/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from sentry.spans.consumers.process_segments import message as message_module
from sentry.spans.consumers.process_segments.message import _verify_compatibility, process_segment
from sentry.spans.consumers.process_segments.shim import build_shim_event_data
from sentry.spans.consumers.process_segments.types import attribute_value
from sentry.testutils.cases import TestCase
from sentry.testutils.helpers.options import override_options
from sentry.testutils.issue_detection.experiments import exclude_experimental_detectors
Expand All @@ -28,7 +29,7 @@ def generate_basic_spans(self):
is_segment=True,
attributes={
"sentry.browser.name": {"value": "Google Chrome"},
"sentry.transaction": {
"sentry.segment.name": {
"value": "/api/0/organizations/{organization_id_or_slug}/n-plus-one/"
},
"sentry.transaction.method": {"value": "GET"},
Expand Down Expand Up @@ -97,7 +98,7 @@ def test_enrich_spans(self) -> None:
child_attrs = child_span["attributes"] or {}
segment_data = segment_span["attributes"] or {}

assert child_attrs["sentry.transaction"] == segment_data["sentry.transaction"]
assert child_attrs["sentry.segment.name"] == segment_data["sentry.segment.name"]
assert child_attrs["sentry.transaction.method"] == segment_data["sentry.transaction.method"]
assert child_attrs["sentry.transaction.op"] == segment_data["sentry.transaction.op"]
assert child_attrs["sentry.user"] == segment_data["sentry.user"]
Expand Down Expand Up @@ -285,26 +286,29 @@ def test_record_signals_agents_via_gen_ai_op_name(self, mock_track):

def test_segment_name_propagation(self) -> None:
child_span, segment_span = self.generate_basic_spans()
segment_span["name"] = "my segment name"
assert (
attribute_value(segment_span, "sentry.segment.name")
== "/api/0/organizations/{organization_id_or_slug}/n-plus-one/"
)
assert attribute_value(child_span, "sentry.segment.name") is None

processed_spans = process_segment([child_span, segment_span])

assert len(processed_spans) == 2
child_span, segment_span = processed_spans
segment_attributes = segment_span["attributes"] or {}
assert segment_attributes["sentry.segment.name"] == {
"type": "string",
"value": "my segment name",
"value": "/api/0/organizations/{organization_id_or_slug}/n-plus-one/",
}
child_attributes = child_span["attributes"] or {}
assert child_attributes["sentry.segment.name"] == {
"type": "string",
"value": "my segment name",
"value": "/api/0/organizations/{organization_id_or_slug}/n-plus-one/",
}

def test_segment_name_propagation_when_name_missing(self) -> None:
child_span, segment_span = self.generate_basic_spans()
del segment_span["name"]
del segment_span["attributes"]["sentry.segment.name"]

processed_spans = process_segment([child_span, segment_span])

Expand Down
Loading