Skip to content

ref(span consumer): Use new reference to transaction name#116646

Draft
lobsterkatie wants to merge 2 commits into
masterfrom
kmclb-switch-from-transaction-to-segment-name
Draft

ref(span consumer): Use new reference to transaction name#116646
lobsterkatie wants to merge 2 commits into
masterfrom
kmclb-switch-from-transaction-to-segment-name

Conversation

@lobsterkatie
Copy link
Copy Markdown
Member

In our Sentry Conventions repo, sentry.transaction is marked as deprecated in favor of sentry.segment.name for the new span schema. The latter should always be there, via one of three routes (either in Relay or an SDK):

  • For transaction-derived spans, it's pulled from event.transaction and added onto the spans during normalization.

  • For OTel spans, it's copied from the span's name in otel_to_sentry_span.

  • For newstyle spans which come from SDKs, it should be there because it's put there by the SDK itself.

(In the case of the two Relay functions, careful readers will note that what's being set is segment_name, not segment.name. That conversion happens during serialization because of the metastructure annotation on the segment_name field in theSpanData struct.)

In my work switching issue detectors to be span-buffer-compatible, I came across three spots (two in code, one in a test) where we're still using the old attribute name. This PR updates them to use the new names.

h/t Claude for his help with the research here

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Backend Test Failures

Failures on 5168322 in this run:

tests/sentry/spans/consumers/process_segments/test_message.py::TestSpansTask::test_segment_name_propagationlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/spans/consumers/process_segments/test_message.py:295: in test_segment_name_propagation
    assert segment_attributes["sentry.segment.name"] == {
E   AssertionError: assert {'value': '/a.../n-plus-one/'} == {'type': 'str...segment name'}
E     
E     Differing items:
E     �[0m{�[33m'�[39;49;00m�[33mvalue�[39;49;00m�[33m'�[39;49;00m: �[33m'�[39;49;00m�[33m/api/0/organizations/�[39;49;00m�[33m{organization_id_or_slug}�[39;49;00m�[33m/n-plus-one/�[39;49;00m�[33m'�[39;49;00m}�[90m�[39;49;00m != �[0m{�[33m'�[39;49;00m�[33mvalue�[39;49;00m�[33m'�[39;49;00m: �[33m'�[39;49;00m�[33mmy segment name�[39;49;00m�[33m'�[39;49;00m}�[90m�[39;49;00m
E     Right contains 1 more item:
E     �[0m{�[33m'�[39;49;00m�[33mtype�[39;49;00m�[33m'�[39;49;00m: �[33m'�[39;49;00m�[33mstring�[39;49;00m�[33m'�[39;49;00m}�[90m�[39;49;00m
E     
E     Full diff:
E     �[0m�[90m �[39;49;00m {�[90m�[39;49;00m
E     �[92m+     'value': '/api/0/organizations/{organization_id_or_slug}/n-plus-one/',�[39;49;00m�[90m�[39;49;00m
E     �[91m-     'type': 'string',�[39;49;00m�[90m�[39;49;00m
E     �[91m-     'value': 'my segment name',�[39;49;00m�[90m�[39;49;00m
E     �[90m �[39;49;00m }�[90m�[39;49;00m
tests/sentry/spans/consumers/process_segments/test_message.py::TestSpansTask::test_segment_name_propagation_when_name_missinglog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/spans/consumers/process_segments/test_message.py:314: in test_segment_name_propagation_when_name_missing
    assert segment_attributes.get("sentry.segment.name") is None
E   AssertionError: assert {'value': '/api/0/organizations/{organization_id_or_slug}/n-plus-one/'} is None
E    +  where {'value': '/api/0/organizations/{organization_id_or_slug}/n-plus-one/'} = <built-in method get of dict object at 0x7f559d7837c0>('sentry.segment.name')
E    +    where <built-in method get of dict object at 0x7f559d7837c0> = {'sentry.browser.name': {'value': 'Google Chrome'}, 'sentry.duration': {'type': 'double', 'value': 0.107}, 'sentry.environment': {'type': 'string', 'value': 'development'}, 'sentry.exclusive_time_ms': {'type': 'double', 'value': 2.0}, ...}.get

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant