From f6905cc1e04dd410e75af49811ad164073a28bf5 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 17 Jul 2026 09:55:02 +0200 Subject: [PATCH 1/6] feat(tracing): Send `sentry.segment.name.source` instead of `sentry.span.source` attribute --- sentry_sdk/integrations/aiohttp.py | 6 ++--- sentry_sdk/integrations/arq.py | 4 +-- sentry_sdk/integrations/asgi.py | 24 ++++++++++------- sentry_sdk/integrations/aws_lambda.py | 4 +-- sentry_sdk/integrations/celery/__init__.py | 2 +- sentry_sdk/integrations/dramatiq.py | 4 +-- sentry_sdk/integrations/gcp.py | 4 +-- sentry_sdk/integrations/grpc/aio/server.py | 4 +-- sentry_sdk/integrations/grpc/server.py | 4 +-- sentry_sdk/integrations/huey.py | 4 +-- sentry_sdk/integrations/ray.py | 4 +-- sentry_sdk/integrations/rq.py | 4 +-- sentry_sdk/integrations/sanic.py | 4 +-- sentry_sdk/integrations/strawberry.py | 6 +++-- sentry_sdk/integrations/tornado.py | 8 +++--- sentry_sdk/integrations/wsgi.py | 4 +-- sentry_sdk/scope.py | 6 ++--- sentry_sdk/traces.py | 26 +++++++++---------- sentry_sdk/tracing_utils.py | 2 +- tests/integrations/aiohttp/test_aiohttp.py | 9 +++++-- tests/integrations/arq/test_arq.py | 2 +- tests/integrations/asgi/test_asgi.py | 17 +++++++----- .../aws_lambda/test_aws_lambda.py | 6 ++--- tests/integrations/bottle/test_bottle.py | 2 +- tests/integrations/celery/test_celery.py | 2 +- tests/integrations/django/test_basic.py | 2 +- tests/integrations/dramatiq/test_dramatiq.py | 2 +- tests/integrations/falcon/test_falcon.py | 2 +- tests/integrations/fastapi/test_fastapi.py | 5 ++-- tests/integrations/flask/test_flask.py | 2 +- tests/integrations/gcp/test_gcp.py | 6 ++--- tests/integrations/grpc/test_grpc.py | 6 ++--- tests/integrations/grpc/test_grpc_aio.py | 4 +-- tests/integrations/huey/test_huey.py | 14 ++++++---- tests/integrations/litestar/test_litestar.py | 2 +- tests/integrations/pyramid/test_pyramid.py | 2 +- tests/integrations/quart/test_quart.py | 2 +- tests/integrations/ray/test_ray.py | 6 ++--- tests/integrations/sanic/test_sanic.py | 2 +- tests/integrations/starlite/test_starlite.py | 2 +- tests/integrations/tornado/test_tornado.py | 2 +- tests/integrations/wsgi/test_wsgi.py | 2 +- 42 files changed, 123 insertions(+), 102 deletions(-) diff --git a/sentry_sdk/integrations/aiohttp.py b/sentry_sdk/integrations/aiohttp.py index 7cddc466ac..c27821d953 100644 --- a/sentry_sdk/integrations/aiohttp.py +++ b/sentry_sdk/integrations/aiohttp.py @@ -23,7 +23,7 @@ ) from sentry_sdk.traces import ( NoOpStreamedSpan, - SegmentSource, + SegmentNameSource, SpanStatus, StreamedSpan, ) @@ -185,7 +185,7 @@ async def sentry_app_handle( attributes={ "sentry.op": OP.HTTP_SERVER, "sentry.origin": AioHttpIntegration.origin, - "sentry.span.source": SegmentSource.ROUTE.value, + "sentry.segment.name.source": SegmentNameSource.ROUTE.value, "http.request.method": request.method, **url_attributes, **client_address_attributes, @@ -302,7 +302,7 @@ async def sentry_urldispatcher_resolve( ): current_span._segment.name = name current_span._segment.set_attribute( - "sentry.span.source", + "sentry.segment.name.source", SEGMENT_SOURCE_FOR_STYLE[integration.transaction_style].value, ) else: diff --git a/sentry_sdk/integrations/arq.py b/sentry_sdk/integrations/arq.py index 011c5e51bf..4cb70f821b 100644 --- a/sentry_sdk/integrations/arq.py +++ b/sentry_sdk/integrations/arq.py @@ -5,7 +5,7 @@ from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version from sentry_sdk.integrations.logging import ignore_logger from sentry_sdk.scope import should_send_default_pii -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing import Transaction, TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled from sentry_sdk.utils import ( @@ -118,7 +118,7 @@ async def _sentry_run_job(self: "Worker", job_id: str, score: int) -> None: attributes={ "sentry.op": OP.QUEUE_TASK_ARQ, "sentry.origin": ArqIntegration.origin, - "sentry.span.source": SegmentSource.TASK, + "sentry.segment.name.source": SegmentNameSource.TASK, SPANDATA.MESSAGING_MESSAGE_ID: job_id, }, parent_span=None, diff --git a/sentry_sdk/integrations/asgi.py b/sentry_sdk/integrations/asgi.py index a360d7af36..e1157dda77 100644 --- a/sentry_sdk/integrations/asgi.py +++ b/sentry_sdk/integrations/asgi.py @@ -31,7 +31,7 @@ SOURCE_FOR_STYLE as SEGMENT_SOURCE_FOR_STYLE, ) from sentry_sdk.traces import ( - SegmentSource, + SegmentNameSource, StreamedSpan, ) from sentry_sdk.tracing import ( @@ -246,7 +246,7 @@ async def _run_app( if span_streaming: segment: "Optional[StreamedSpan]" = None attributes: "Attributes" = { - "sentry.span.source": getattr( + "sentry.segment.name.source": getattr( transaction_source, "value", transaction_source ), "sentry.origin": self.span_origin, @@ -384,11 +384,13 @@ async def _sentry_wrapped_send( already_set = ( span is not None and span.name != _DEFAULT_TRANSACTION_NAME - and span.get_attributes().get("sentry.span.source") + and span.get_attributes().get( + "sentry.segment.name.source" + ) in [ - SegmentSource.COMPONENT.value, - SegmentSource.ROUTE.value, - SegmentSource.CUSTOM.value, + SegmentNameSource.COMPONENT.value, + SegmentNameSource.ROUTE.value, + SegmentNameSource.CUSTOM.value, ] ) with capture_internal_exceptions(): @@ -399,7 +401,9 @@ async def _sentry_wrapped_send( ) ) span.name = name - span.set_attribute("sentry.span.source", source) + span.set_attribute( + "sentry.segment.name.source", source + ) finally: _asgi_middleware_applied.set(False) @@ -514,7 +518,7 @@ def _get_segment_name_and_source( asgi_scope=asgi_scope, root_path_in_path=self.root_path_in_path ), ) - source = SegmentSource.URL.value + source = SegmentNameSource.URL.value elif segment_style == "url": # FastAPI includes the route object in the scope to let Sentry extract the @@ -533,11 +537,11 @@ def _get_segment_name_and_source( asgi_scope=asgi_scope, root_path_in_path=self.root_path_in_path ), ) - source = SegmentSource.URL.value + source = SegmentNameSource.URL.value if name is None: name = _DEFAULT_TRANSACTION_NAME - source = SegmentSource.ROUTE.value + source = SegmentNameSource.ROUTE.value return name, source return name, source diff --git a/sentry_sdk/integrations/aws_lambda.py b/sentry_sdk/integrations/aws_lambda.py index c7fe77714a..762a243735 100644 --- a/sentry_sdk/integrations/aws_lambda.py +++ b/sentry_sdk/integrations/aws_lambda.py @@ -18,7 +18,7 @@ CLOUD_PROVIDER, ) from sentry_sdk.scope import Scope, should_send_default_pii -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing import TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled from sentry_sdk.utils import ( @@ -185,7 +185,7 @@ def sentry_handler( attributes={ "sentry.op": OP.FUNCTION_AWS, "sentry.origin": AwsLambdaIntegration.origin, - "sentry.span.source": SegmentSource.COMPONENT, + "sentry.segment.name.source": SegmentNameSource.COMPONENT, "cloud.region": aws_region, "cloud.resource_id": aws_context.invoked_function_arn, "cloud.platform": CLOUD_PLATFORM.AWS_LAMBDA, diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index a4abac4618..21ef36f152 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -361,7 +361,7 @@ def _inner(*args: "Any", **kwargs: "Any") -> "Any": parent_span=None, # make this a segment attributes={ "sentry.origin": CeleryIntegration.origin, - "sentry.span.source": TransactionSource.TASK.value, + "sentry.segment.name.source": TransactionSource.TASK.value, "sentry.op": OP.QUEUE_TASK_CELERY, }, ) diff --git a/sentry_sdk/integrations/dramatiq.py b/sentry_sdk/integrations/dramatiq.py index 195e6c1c51..2840c24fe5 100644 --- a/sentry_sdk/integrations/dramatiq.py +++ b/sentry_sdk/integrations/dramatiq.py @@ -6,7 +6,7 @@ from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS from sentry_sdk.integrations import DidNotEnable, Integration from sentry_sdk.integrations._wsgi_common import request_body_within_bounds -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing import ( BAGGAGE_HEADER_NAME, SENTRY_TRACE_HEADER_NAME, @@ -139,7 +139,7 @@ def before_process_message(self, broker: "Broker", message: "Message[R]") -> Non attributes={ "sentry.op": OP.QUEUE_TASK_DRAMATIQ, "sentry.origin": DramatiqIntegration.origin, - "sentry.span.source": SegmentSource.TASK.value, + "sentry.segment.name.source": SegmentNameSource.TASK.value, SPANDATA.MESSAGING_DESTINATION_NAME: message.queue_name, }, parent_span=None, diff --git a/sentry_sdk/integrations/gcp.py b/sentry_sdk/integrations/gcp.py index 91a62b3a81..29095343eb 100644 --- a/sentry_sdk/integrations/gcp.py +++ b/sentry_sdk/integrations/gcp.py @@ -12,7 +12,7 @@ from sentry_sdk.integrations._wsgi_common import _filter_headers from sentry_sdk.integrations.cloud_resource_context import CLOUD_PROVIDER from sentry_sdk.scope import Scope, should_send_default_pii -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing import TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled from sentry_sdk.utils import ( @@ -138,7 +138,7 @@ def sentry_func( attributes={ "sentry.op": OP.FUNCTION_GCP, "sentry.origin": GcpIntegration.origin, - "sentry.span.source": SegmentSource.COMPONENT, + "sentry.segment.name.source": SegmentNameSource.COMPONENT, "cloud.provider": CLOUD_PROVIDER.GCP, "faas.name": function_name, **header_attributes, diff --git a/sentry_sdk/integrations/grpc/aio/server.py b/sentry_sdk/integrations/grpc/aio/server.py index 010337e98c..15dcacab59 100644 --- a/sentry_sdk/integrations/grpc/aio/server.py +++ b/sentry_sdk/integrations/grpc/aio/server.py @@ -4,7 +4,7 @@ from sentry_sdk.consts import OP from sentry_sdk.integrations import DidNotEnable from sentry_sdk.integrations.grpc.consts import SPAN_ORIGIN -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing import TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled from sentry_sdk.utils import event_from_exception @@ -67,7 +67,7 @@ async def wrapped(request: "Any", context: "ServicerContext") -> "Any": name=name, attributes={ "sentry.op": OP.GRPC_SERVER, - "sentry.span.source": SegmentSource.CUSTOM.value, + "sentry.segment.name.source": SegmentNameSource.CUSTOM.value, "sentry.origin": SPAN_ORIGIN, }, parent_span=None, diff --git a/sentry_sdk/integrations/grpc/server.py b/sentry_sdk/integrations/grpc/server.py index 1cba1d4b85..9b091c258d 100644 --- a/sentry_sdk/integrations/grpc/server.py +++ b/sentry_sdk/integrations/grpc/server.py @@ -4,7 +4,7 @@ from sentry_sdk.consts import OP from sentry_sdk.integrations import DidNotEnable from sentry_sdk.integrations.grpc.consts import SPAN_ORIGIN -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing import TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled @@ -58,7 +58,7 @@ def behavior(request: "Message", context: "ServicerContext") -> "Message": name=name, attributes={ "sentry.op": OP.GRPC_SERVER, - "sentry.span.source": SegmentSource.CUSTOM.value, + "sentry.segment.name.source": SegmentNameSource.CUSTOM.value, "sentry.origin": SPAN_ORIGIN, }, parent_span=None, diff --git a/sentry_sdk/integrations/huey.py b/sentry_sdk/integrations/huey.py index 70814d4b7f..7d0009b405 100644 --- a/sentry_sdk/integrations/huey.py +++ b/sentry_sdk/integrations/huey.py @@ -7,7 +7,7 @@ from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS from sentry_sdk.integrations import DidNotEnable, Integration from sentry_sdk.scope import should_send_default_pii -from sentry_sdk.traces import SegmentSource, SpanStatus, StreamedSpan +from sentry_sdk.traces import SegmentNameSource, SpanStatus, StreamedSpan from sentry_sdk.tracing import ( BAGGAGE_HEADER_NAME, SENTRY_TRACE_HEADER_NAME, @@ -220,7 +220,7 @@ def _sentry_execute( attributes={ "sentry.op": OP.QUEUE_TASK_HUEY, "sentry.origin": HueyIntegration.origin, - "sentry.span.source": SegmentSource.TASK, + "sentry.segment.name.source": SegmentNameSource.TASK, SPANDATA.MESSAGING_DESTINATION_NAME: self.name, "messaging.message.id": task.id, "messaging.message.system": "huey", diff --git a/sentry_sdk/integrations/ray.py b/sentry_sdk/integrations/ray.py index f48bd59791..744cc266cf 100644 --- a/sentry_sdk/integrations/ray.py +++ b/sentry_sdk/integrations/ray.py @@ -5,7 +5,7 @@ import sentry_sdk from sentry_sdk.consts import OP, SPANSTATUS from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing import TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled from sentry_sdk.utils import ( @@ -104,7 +104,7 @@ def new_func( attributes={ "sentry.op": OP.QUEUE_TASK_RAY, "sentry.origin": RayIntegration.origin, - "sentry.span.source": SegmentSource.TASK, + "sentry.segment.name.source": SegmentNameSource.TASK, }, parent_span=None, ): diff --git a/sentry_sdk/integrations/rq.py b/sentry_sdk/integrations/rq.py index fd679d1039..4a2748113b 100644 --- a/sentry_sdk/integrations/rq.py +++ b/sentry_sdk/integrations/rq.py @@ -7,7 +7,7 @@ from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version from sentry_sdk.integrations.logging import ignore_logger from sentry_sdk.scope import Scope, should_send_default_pii -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing import TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled from sentry_sdk.utils import ( @@ -91,7 +91,7 @@ def sentry_patched_perform_job( attributes={ "sentry.op": OP.QUEUE_TASK_RQ, "sentry.origin": RqIntegration.origin, - "sentry.span.source": SegmentSource.TASK, + "sentry.segment.name.source": SegmentNameSource.TASK, SPANDATA.MESSAGING_MESSAGE_ID: job.id, SPANDATA.MESSAGING_DESTINATION_NAME: queue.name, }, diff --git a/sentry_sdk/integrations/sanic.py b/sentry_sdk/integrations/sanic.py index 908fceb0cf..7f98eb71b3 100644 --- a/sentry_sdk/integrations/sanic.py +++ b/sentry_sdk/integrations/sanic.py @@ -12,7 +12,7 @@ from sentry_sdk.integrations._wsgi_common import RequestExtractor, _filter_headers from sentry_sdk.integrations.logging import ignore_logger from sentry_sdk.scope import should_send_default_pii -from sentry_sdk.traces import SegmentSource, StreamedSpan +from sentry_sdk.traces import SegmentNameSource, StreamedSpan from sentry_sdk.tracing import TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled from sentry_sdk.utils import ( @@ -202,7 +202,7 @@ async def _context_enter(request: "Request") -> None: attributes={ "sentry.op": OP.HTTP_SERVER, "sentry.origin": SanicIntegration.origin, - "sentry.span.source": SegmentSource.URL.value, + "sentry.segment.name.source": SegmentNameSource.URL.value, }, parent_span=None, ) diff --git a/sentry_sdk/integrations/strawberry.py b/sentry_sdk/integrations/strawberry.py index 4e41133f3a..97c0289267 100644 --- a/sentry_sdk/integrations/strawberry.py +++ b/sentry_sdk/integrations/strawberry.py @@ -8,7 +8,7 @@ from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version from sentry_sdk.integrations.logging import ignore_logger from sentry_sdk.scope import should_send_default_pii -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.tracing import Span, TransactionSource from sentry_sdk.tracing_utils import StreamedSpan, has_span_streaming_enabled from sentry_sdk.utils import ( @@ -231,7 +231,9 @@ def on_operation(self) -> "Generator[None, None, None]": if type(graphql_span) is StreamedSpan: if self.execution_context.operation_name: segment = graphql_span._segment - segment.set_attribute("sentry.span.source", SegmentSource.COMPONENT) + segment.set_attribute( + "sentry.segment.name.source", SegmentNameSource.COMPONENT + ) segment.set_attribute("sentry.op", op) segment.name = self.execution_context.operation_name elif isinstance(graphql_span, Span): diff --git a/sentry_sdk/integrations/tornado.py b/sentry_sdk/integrations/tornado.py index 859b0d0870..ed603b6152 100644 --- a/sentry_sdk/integrations/tornado.py +++ b/sentry_sdk/integrations/tornado.py @@ -14,7 +14,7 @@ ) from sentry_sdk.integrations.logging import ignore_logger from sentry_sdk.scope import should_send_default_pii -from sentry_sdk.traces import SegmentSource, StreamedSpan +from sentry_sdk.traces import SegmentNameSource, StreamedSpan from sentry_sdk.tracing import TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled from sentry_sdk.utils import ( @@ -138,7 +138,7 @@ def _handle_request_impl(self: "RequestHandler") -> "Generator[None, None, None] attributes={ "sentry.op": OP.HTTP_SERVER, "sentry.origin": TornadoIntegration.origin, - "sentry.span.source": SegmentSource.ROUTE, + "sentry.segment.name.source": SegmentNameSource.ROUTE, }, parent_span=None, ) @@ -177,8 +177,8 @@ def _handle_request_impl(self: "RequestHandler") -> "Generator[None, None, None] if span_name: span.name = span_name span.set_attribute( - "sentry.span.source", - SegmentSource.COMPONENT, + "sentry.segment.name.source", + SegmentNameSource.COMPONENT, ) with capture_internal_exceptions(): diff --git a/sentry_sdk/integrations/wsgi.py b/sentry_sdk/integrations/wsgi.py index 168b889b60..d3b91ff1ba 100644 --- a/sentry_sdk/integrations/wsgi.py +++ b/sentry_sdk/integrations/wsgi.py @@ -12,7 +12,7 @@ ) from sentry_sdk.scope import Scope, should_send_default_pii, use_isolation_scope from sentry_sdk.sessions import track_session -from sentry_sdk.traces import SegmentSource, StreamedSpan +from sentry_sdk.traces import SegmentNameSource, StreamedSpan from sentry_sdk.tracing import Span, TransactionSource from sentry_sdk.tracing_utils import has_span_streaming_enabled from sentry_sdk.utils import ( @@ -144,7 +144,7 @@ def __call__( span_ctx = sentry_sdk.traces.start_span( name=_DEFAULT_TRANSACTION_NAME, attributes={ - "sentry.span.source": SegmentSource.ROUTE, + "sentry.segment.name.source": SegmentNameSource.ROUTE, "sentry.origin": self.span_origin, "sentry.op": OP.HTTP_SERVER, }, diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index d6d50a4a2b..617250f562 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -867,7 +867,7 @@ def set_transaction_name(self, name: str, source: "Optional[str]" = None) -> Non self._span._segment.name = name if source: self._span._segment.set_attribute( - "sentry.span.source", getattr(source, "value", source) + "sentry.segment.name.source", getattr(source, "value", source) ) elif self._span.containing_transaction: @@ -926,9 +926,9 @@ def streamed_span(self, span: "Optional[StreamedSpan]") -> None: # is used for populating events and linking them to segments if type(span) is StreamedSpan and span._is_segment(): self._transaction = span.name - if span._attributes.get("sentry.span.source"): + if span._attributes.get("sentry.segment.name.source"): self._transaction_info["source"] = str( - span._attributes["sentry.span.source"] + span._attributes["sentry.segment.name.source"] ) @property diff --git a/sentry_sdk/traces.py b/sentry_sdk/traces.py index 9478678dc3..560b4e726a 100644 --- a/sentry_sdk/traces.py +++ b/sentry_sdk/traces.py @@ -65,9 +65,9 @@ def __str__(self) -> str: _VALID_SPAN_STATUSES = frozenset(e.value for e in SpanStatus) -# Segment source, see -# https://getsentry.github.io/sentry-conventions/generated/attributes/sentry.html#sentryspansource -class SegmentSource(str, Enum): +# Segment name source, see +# https://getsentry.github.io/sentry-conventions/attributes/sentry/#sentry-segment-name-source +class SegmentNameSource(str, Enum): COMPONENT = "component" CUSTOM = "custom" ROUTE = "route" @@ -81,20 +81,20 @@ def __str__(self) -> str: # These are typically high cardinality and the server hates them LOW_QUALITY_SEGMENT_SOURCES = [ - SegmentSource.URL, + SegmentNameSource.URL, ] SOURCE_FOR_STYLE = { - "endpoint": SegmentSource.COMPONENT, - "function_name": SegmentSource.COMPONENT, - "handler_name": SegmentSource.COMPONENT, - "method_and_path_pattern": SegmentSource.ROUTE, - "path": SegmentSource.URL, - "route_name": SegmentSource.COMPONENT, - "route_pattern": SegmentSource.ROUTE, - "uri_template": SegmentSource.ROUTE, - "url": SegmentSource.ROUTE, + "endpoint": SegmentNameSource.COMPONENT, + "function_name": SegmentNameSource.COMPONENT, + "handler_name": SegmentNameSource.COMPONENT, + "method_and_path_pattern": SegmentNameSource.ROUTE, + "path": SegmentNameSource.URL, + "route_name": SegmentNameSource.COMPONENT, + "route_pattern": SegmentNameSource.ROUTE, + "uri_template": SegmentNameSource.ROUTE, + "url": SegmentNameSource.ROUTE, } diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index 8cf11d01f7..a6533eec16 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -886,7 +886,7 @@ def populate_from_segment(cls, segment: "StreamedSpan") -> "Baggage": sentry_items["org_id"] = client.parsed_dsn.org_id if ( - segment.get_attributes().get("sentry.span.source") + segment.get_attributes().get("sentry.segment.name.source") not in LOW_QUALITY_SEGMENT_SOURCES ) and segment.name: sentry_items["transaction"] = segment.name diff --git a/tests/integrations/aiohttp/test_aiohttp.py b/tests/integrations/aiohttp/test_aiohttp.py index 6661af807e..e21971218c 100644 --- a/tests/integrations/aiohttp/test_aiohttp.py +++ b/tests/integrations/aiohttp/test_aiohttp.py @@ -1177,7 +1177,7 @@ async def hello(request): assert server_span["attributes"]["sentry.op"] == "http.server" assert server_span["attributes"]["sentry.origin"] == "auto.http.aiohttp" assert server_span["attributes"]["http.response.status_code"] == 200 - assert server_span["attributes"]["sentry.span.source"] == "component" + assert server_span["attributes"]["sentry.segment.name.source"] == "component" assert server_span["status"] == "ok" # No query string on the request, so the attribute should be omitted. assert "url.query" not in server_span["attributes"] @@ -1379,7 +1379,7 @@ async def hello(request): assert server_segment["name"] == expected_name assert server_segment["is_segment"] - assert server_segment["attributes"]["sentry.span.source"] == expected_source + assert server_segment["attributes"]["sentry.segment.name.source"] == expected_source @pytest.mark.asyncio @@ -1609,6 +1609,11 @@ async def hello(request): child_span, server_span = [item.payload for item in items] + assert server_span["attributes"]["sentry.segment.name.source"] == "component" + assert "sentry.segment.name.source" not in child_span["attributes"] + assert "sentry.span.source" not in server_span["attributes"] + assert "sentry.span.source" not in child_span["attributes"] + if send_default_pii: assert server_span["attributes"]["user.ip_address"] == "127.0.0.1" assert child_span["attributes"]["user.ip_address"] == "127.0.0.1" diff --git a/tests/integrations/arq/test_arq.py b/tests/integrations/arq/test_arq.py index d962bf61c7..c6342dc1ae 100644 --- a/tests/integrations/arq/test_arq.py +++ b/tests/integrations/arq/test_arq.py @@ -368,7 +368,7 @@ async def division(_, a, b=0): ] division_span = next(span for span in task_spans if span["name"] == "division") - assert division_span["attributes"]["sentry.span.source"] == "task" + assert division_span["attributes"]["sentry.segment.name.source"] == "task" assert ( division_span["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME] == worker.queue_name diff --git a/tests/integrations/asgi/test_asgi.py b/tests/integrations/asgi/test_asgi.py index 3bce0d1e10..72addcd6ab 100644 --- a/tests/integrations/asgi/test_asgi.py +++ b/tests/integrations/asgi/test_asgi.py @@ -205,7 +205,7 @@ async def test_capture_transaction( assert span["is_segment"] is True assert span["name"] == "/some_url" - assert span["attributes"]["sentry.span.source"] == "url" + assert span["attributes"]["sentry.segment.name.source"] == "url" assert span["attributes"]["sentry.op"] == "http.server" assert span["attributes"]["network.protocol.name"] == "http" @@ -561,7 +561,7 @@ async def test_websocket( assert span.type == "span" span = span.payload assert span["name"] == request_url - assert span["attributes"]["sentry.span.source"] == "url" + assert span["attributes"]["sentry.segment.name.source"] == "url" else: msg_event, error_event, transaction_event = events @@ -678,7 +678,7 @@ async def test_transaction_style( span = items[0].payload assert span["name"] == expected_transaction - assert span["attributes"]["sentry.span.source"] == expected_source + assert span["attributes"]["sentry.segment.name.source"] == expected_source else: (transaction_event,) = events @@ -891,7 +891,10 @@ async def test_transaction_name( span = items[0].payload assert span["name"] == expected_transaction_name - assert span["attributes"]["sentry.span.source"] == expected_transaction_source + assert ( + span["attributes"]["sentry.segment.name.source"] + == expected_transaction_source + ) else: (transaction_envelope,) = envelopes @@ -944,7 +947,9 @@ def dummy_traces_sampler(sampling_context): if span_streaming: assert sampling_context["span_context"]["name"] == expected_transaction_name assert ( - sampling_context["span_context"]["attributes"]["sentry.span.source"] + sampling_context["span_context"]["attributes"][ + "sentry.segment.name.source" + ] == expected_transaction_source ) else: @@ -1006,7 +1011,7 @@ async def test_custom_transaction_name( assert span["is_segment"] is True assert span["name"] == "foobar" - assert span["attributes"]["sentry.span.source"] == "custom" + assert span["attributes"]["sentry.segment.name.source"] == "custom" else: (transaction_event,) = events diff --git a/tests/integrations/aws_lambda/test_aws_lambda.py b/tests/integrations/aws_lambda/test_aws_lambda.py index ec01284e58..0bdd66ab05 100644 --- a/tests/integrations/aws_lambda/test_aws_lambda.py +++ b/tests/integrations/aws_lambda/test_aws_lambda.py @@ -553,7 +553,7 @@ def test_span_streaming_no_error(lambda_client, test_environment): assert _get_span_attr(attrs, "sentry.op") == "function.aws" assert _get_span_attr(attrs, "sentry.origin") == "auto.function.aws_lambda" - assert _get_span_attr(attrs, "sentry.span.source") == "component" + assert _get_span_attr(attrs, "sentry.segment.name.source") == "component" assert _get_span_attr(attrs, "cloud.provider") == "aws" assert _get_span_attr(attrs, "cloud.platform") == "aws_lambda" assert ( @@ -603,7 +603,7 @@ def test_span_streaming_error(lambda_client, test_environment): assert _get_span_attr(attrs, "sentry.op") == "function.aws" assert _get_span_attr(attrs, "sentry.origin") == "auto.function.aws_lambda" - assert _get_span_attr(attrs, "sentry.span.source") == "component" + assert _get_span_attr(attrs, "sentry.segment.name.source") == "component" assert _get_span_attr(attrs, "cloud.provider") == "aws" assert _get_span_attr(attrs, "cloud.platform") == "aws_lambda" assert ( @@ -656,7 +656,7 @@ def test_span_streaming_trace_continuation(lambda_client, test_environment): attrs = segment_span["attributes"] assert _get_span_attr(attrs, "sentry.op") == "function.aws" assert _get_span_attr(attrs, "sentry.origin") == "auto.function.aws_lambda" - assert _get_span_attr(attrs, "sentry.span.source") == "component" + assert _get_span_attr(attrs, "sentry.segment.name.source") == "component" assert _get_span_attr(attrs, "cloud.provider") == "aws" assert _get_span_attr(attrs, "cloud.platform") == "aws_lambda" assert _get_span_attr(attrs, "cloud.region") == "us-east-1" diff --git a/tests/integrations/bottle/test_bottle.py b/tests/integrations/bottle/test_bottle.py index 6a36f8efd5..cbe841133b 100644 --- a/tests/integrations/bottle/test_bottle.py +++ b/tests/integrations/bottle/test_bottle.py @@ -659,7 +659,7 @@ def named_hi(): assert segment["is_segment"] is True assert segment["name"].endswith(expected_name) - assert segment["attributes"]["sentry.span.source"] == expected_source + assert segment["attributes"]["sentry.segment.name.source"] == expected_source def test_span_streaming_with_error(sentry_init, capture_items): diff --git a/tests/integrations/celery/test_celery.py b/tests/integrations/celery/test_celery.py index 944fabb6e4..ab382e982f 100644 --- a/tests/integrations/celery/test_celery.py +++ b/tests/integrations/celery/test_celery.py @@ -274,7 +274,7 @@ def dummy_task(x, y): assert execution_span["name"] == "dummy_task" assert execution_span["is_segment"] is True - assert execution_span["attributes"]["sentry.span.source"] == "task" + assert execution_span["attributes"]["sentry.segment.name.source"] == "task" assert execution_span["trace_id"] == span.trace_id if task_fails: assert execution_span["status"] == "error" diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index cf8dd6be75..812b34e379 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -1277,7 +1277,7 @@ def test_transaction_style( spans = [item.payload for item in items if item.type == "span"] assert spans[2]["is_segment"] is True - assert spans[2]["attributes"]["sentry.span.source"] == expected_source + assert spans[2]["attributes"]["sentry.segment.name.source"] == expected_source (event,) = (item.payload for item in items if item.type == "event") else: diff --git a/tests/integrations/dramatiq/test_dramatiq.py b/tests/integrations/dramatiq/test_dramatiq.py index dae5b6a0a1..2fa967894c 100644 --- a/tests/integrations/dramatiq/test_dramatiq.py +++ b/tests/integrations/dramatiq/test_dramatiq.py @@ -171,7 +171,7 @@ def dummy_actor(x, y): assert segment["name"] == "dummy_actor" assert segment["is_segment"] is True assert segment["attributes"]["sentry.op"] == "queue.task.dramatiq" - assert segment["attributes"]["sentry.span.source"] == "task" + assert segment["attributes"]["sentry.segment.name.source"] == "task" assert ( segment["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME] == dummy_actor.queue_name diff --git a/tests/integrations/falcon/test_falcon.py b/tests/integrations/falcon/test_falcon.py index 31c5f5d8b4..6560da004b 100644 --- a/tests/integrations/falcon/test_falcon.py +++ b/tests/integrations/falcon/test_falcon.py @@ -139,7 +139,7 @@ def test_transaction_style( spans = [item.payload for item in items if item.type == "span"] spans = [span for span in spans if span["name"] == expected_transaction] assert len(spans) == 1 - assert spans[0]["attributes"]["sentry.span.source"] == expected_source + assert spans[0]["attributes"]["sentry.segment.name.source"] == expected_source else: events = capture_events() diff --git a/tests/integrations/fastapi/test_fastapi.py b/tests/integrations/fastapi/test_fastapi.py index d91927a644..d27d27d1f7 100644 --- a/tests/integrations/fastapi/test_fastapi.py +++ b/tests/integrations/fastapi/test_fastapi.py @@ -725,7 +725,8 @@ def test_transaction_name( segment = segments[0] assert segment["name"] == expected_transaction_name assert ( - segment["attributes"]["sentry.span.source"] == expected_transaction_source + segment["attributes"]["sentry.segment.name.source"] + == expected_transaction_source ) else: (_, transaction_envelope) = envelopes @@ -780,7 +781,7 @@ async def get_user(user_id: int): assert len(segments) == 1 segment = segments[0] assert segment["name"] == "/api/users/{user_id}" - assert segment["attributes"]["sentry.span.source"] == "route" + assert segment["attributes"]["sentry.segment.name.source"] == "route" else: (transaction_envelope,) = envelopes transaction_event = transaction_envelope.get_transaction_event() diff --git a/tests/integrations/flask/test_flask.py b/tests/integrations/flask/test_flask.py index 87e0b959cc..7a5bf6215d 100644 --- a/tests/integrations/flask/test_flask.py +++ b/tests/integrations/flask/test_flask.py @@ -128,7 +128,7 @@ def test_transaction_or_segment_style( assert len(spans) == 1 (segment,) = spans assert segment["name"] == expected_transaction - assert segment["attributes"]["sentry.span.source"] == expected_source + assert segment["attributes"]["sentry.segment.name.source"] == expected_source else: (_, event) = events assert event["transaction"] == expected_transaction diff --git a/tests/integrations/gcp/test_gcp.py b/tests/integrations/gcp/test_gcp.py index 86638b1644..d1e4e373e9 100644 --- a/tests/integrations/gcp/test_gcp.py +++ b/tests/integrations/gcp/test_gcp.py @@ -611,7 +611,7 @@ def cloud_function(functionhandler, event): assert segment_span["name"] == "Google Cloud function" assert segment_span["attributes"]["sentry.op"] == "function.gcp" assert segment_span["attributes"]["sentry.origin"] == "auto.function.gcp" - assert segment_span["attributes"]["sentry.span.source"] == "component" + assert segment_span["attributes"]["sentry.segment.name.source"] == "component" assert segment_span["attributes"]["cloud.provider"] == "gcp" assert segment_span["attributes"]["faas.name"] == "Google Cloud function" assert segment_span["attributes"]["gcp.project.id"] == "serverless_project" @@ -651,7 +651,7 @@ def cloud_function(functionhandler, event): assert segment_span["name"] == "Google Cloud function" assert segment_span["attributes"]["sentry.op"] == "function.gcp" assert segment_span["attributes"]["sentry.origin"] == "auto.function.gcp" - assert segment_span["attributes"]["sentry.span.source"] == "component" + assert segment_span["attributes"]["sentry.segment.name.source"] == "component" assert segment_span["attributes"]["cloud.provider"] == "gcp" assert segment_span["attributes"]["faas.name"] == "Google Cloud function" assert segment_span["attributes"]["gcp.project.id"] == "serverless_project" @@ -700,7 +700,7 @@ def cloud_function(functionhandler, event): assert segment_span["name"] == "Google Cloud function" assert segment_span["attributes"]["sentry.op"] == "function.gcp" assert segment_span["attributes"]["sentry.origin"] == "auto.function.gcp" - assert segment_span["attributes"]["sentry.span.source"] == "component" + assert segment_span["attributes"]["sentry.segment.name.source"] == "component" assert segment_span["attributes"]["cloud.provider"] == "gcp" assert segment_span["attributes"]["faas.name"] == "Google Cloud function" assert segment_span["attributes"]["gcp.project.id"] == "serverless_project" diff --git a/tests/integrations/grpc/test_grpc.py b/tests/integrations/grpc/test_grpc.py index 7932b434d4..301dfded8a 100644 --- a/tests/integrations/grpc/test_grpc.py +++ b/tests/integrations/grpc/test_grpc.py @@ -85,7 +85,7 @@ def test_grpc_server_starts_transaction( spans = [item["payload"] for item in items if item["type"] == "span"] span = spans[0] - assert spans[1]["attributes"]["sentry.span.source"] == "custom" + assert spans[1]["attributes"]["sentry.segment.name.source"] == "custom" assert spans[1]["attributes"]["sentry.op"] == OP.GRPC_SERVER assert span["attributes"]["sentry.op"] == "test" else: @@ -148,7 +148,7 @@ def test_grpc_server_other_interceptors( spans = [item["payload"] for item in items if item["type"] == "span"] span = spans[0] - assert spans[1]["attributes"]["sentry.span.source"] == "custom" + assert spans[1]["attributes"]["sentry.segment.name.source"] == "custom" assert spans[1]["attributes"]["sentry.op"] == OP.GRPC_SERVER assert span["attributes"]["sentry.op"] == "test" else: @@ -223,7 +223,7 @@ def test_grpc_server_continues_transaction( spans = [item["payload"] for item in items if item["type"] == "span"] span = spans[0] - assert spans[1]["attributes"]["sentry.span.source"] == "custom" + assert spans[1]["attributes"]["sentry.segment.name.source"] == "custom" assert spans[1]["attributes"]["sentry.op"] == OP.GRPC_SERVER assert spans[1]["trace_id"] == segment_span.trace_id assert span["attributes"]["sentry.op"] == "test" diff --git a/tests/integrations/grpc/test_grpc_aio.py b/tests/integrations/grpc/test_grpc_aio.py index 60dfcb1239..3ff2f77d23 100644 --- a/tests/integrations/grpc/test_grpc_aio.py +++ b/tests/integrations/grpc/test_grpc_aio.py @@ -140,7 +140,7 @@ async def test_grpc_server_starts_transaction( spans = [item.payload for item in items] span = spans[0] - assert spans[1]["attributes"]["sentry.span.source"] == "custom" + assert spans[1]["attributes"]["sentry.segment.name.source"] == "custom" assert spans[1]["attributes"]["sentry.op"] == OP.GRPC_SERVER assert span["attributes"]["sentry.op"] == "test" else: @@ -200,7 +200,7 @@ async def test_grpc_server_continues_transaction( spans = [item.payload for item in items] span = spans[0] - assert spans[1]["attributes"]["sentry.span.source"] == "custom" + assert spans[1]["attributes"]["sentry.segment.name.source"] == "custom" assert spans[1]["attributes"]["sentry.op"] == OP.GRPC_SERVER assert spans[1]["trace_id"] == segment_span.trace_id assert span["attributes"]["sentry.op"] == "test" diff --git a/tests/integrations/huey/test_huey.py b/tests/integrations/huey/test_huey.py index 93e24a96d6..6f6eee1e51 100644 --- a/tests/integrations/huey/test_huey.py +++ b/tests/integrations/huey/test_huey.py @@ -9,7 +9,7 @@ from sentry_sdk import start_transaction from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations.huey import HueyIntegration -from sentry_sdk.traces import SegmentSource, SpanStatus +from sentry_sdk.traces import SegmentNameSource, SpanStatus from sentry_sdk.utils import parse_version HUEY_VERSION = parse_version(HUEY_VERSION) @@ -446,7 +446,8 @@ def task2(): assert task1_execute_span["attributes"]["sentry.op"] == "queue.task.huey" assert task1_execute_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert ( - task1_execute_span["attributes"]["sentry.span.source"] == SegmentSource.TASK + task1_execute_span["attributes"]["sentry.segment.name.source"] + == SegmentNameSource.TASK ) assert task1_execute_span["attributes"]["messaging.message.id"] is not None assert task1_execute_span["attributes"]["messaging.message.retry.count"] == 0 @@ -458,7 +459,8 @@ def task2(): assert task2_execute_span["attributes"]["sentry.op"] == "queue.task.huey" assert task2_execute_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert ( - task2_execute_span["attributes"]["sentry.span.source"] == SegmentSource.TASK + task2_execute_span["attributes"]["sentry.segment.name.source"] + == SegmentNameSource.TASK ) else: @@ -569,7 +571,8 @@ def task2(results): assert task1_execute_span["attributes"]["sentry.op"] == "queue.task.huey" assert task1_execute_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert ( - task1_execute_span["attributes"]["sentry.span.source"] == SegmentSource.TASK + task1_execute_span["attributes"]["sentry.segment.name.source"] + == SegmentNameSource.TASK ) # chord callback (task2) is enqueued during task1's execution assert task2_enqueue_span["name"] == "task2" @@ -586,7 +589,8 @@ def task2(results): assert task2_execute_span["attributes"]["sentry.op"] == "queue.task.huey" assert task2_execute_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert ( - task2_execute_span["attributes"]["sentry.span.source"] == SegmentSource.TASK + task2_execute_span["attributes"]["sentry.segment.name.source"] + == SegmentNameSource.TASK ) else: events = capture_events() diff --git a/tests/integrations/litestar/test_litestar.py b/tests/integrations/litestar/test_litestar.py index 4abb037e36..bbd266e7bf 100644 --- a/tests/integrations/litestar/test_litestar.py +++ b/tests/integrations/litestar/test_litestar.py @@ -187,7 +187,7 @@ def test_transaction_name_and_source( spans = [span for span in spans if expected_tx_name in span["name"]] assert len(spans) == 1 - assert spans[0]["attributes"]["sentry.span.source"] == "component" + assert spans[0]["attributes"]["sentry.segment.name.source"] == "component" else: events = capture_events() diff --git a/tests/integrations/pyramid/test_pyramid.py b/tests/integrations/pyramid/test_pyramid.py index ab8985c5bc..ad51968f95 100644 --- a/tests/integrations/pyramid/test_pyramid.py +++ b/tests/integrations/pyramid/test_pyramid.py @@ -169,7 +169,7 @@ def test_transaction_style( assert len(spans) == 1 (segment,) = spans assert segment["name"] == expected_transaction - assert segment["attributes"]["sentry.span.source"] == expected_source + assert segment["attributes"]["sentry.segment.name.source"] == expected_source else: (_, transaction_event) = events assert transaction_event["transaction"] == expected_transaction diff --git a/tests/integrations/quart/test_quart.py b/tests/integrations/quart/test_quart.py index 730b24ef33..07e5672ddd 100644 --- a/tests/integrations/quart/test_quart.py +++ b/tests/integrations/quart/test_quart.py @@ -751,7 +751,7 @@ async def test_span_streaming_transaction_style( segment = spans[0] assert segment["is_segment"] is True assert segment["name"] == expected_name - assert segment["attributes"]["sentry.span.source"] == expected_source + assert segment["attributes"]["sentry.segment.name.source"] == expected_source @pytest.mark.asyncio diff --git a/tests/integrations/ray/test_ray.py b/tests/integrations/ray/test_ray.py index 9b5f21f0fa..62b0d3f104 100644 --- a/tests/integrations/ray/test_ray.py +++ b/tests/integrations/ray/test_ray.py @@ -11,7 +11,7 @@ from sentry_sdk.envelope import Envelope from sentry_sdk.integrations.ray import RayIntegration from sentry_sdk.integrations.stdlib import StdlibIntegration -from sentry_sdk.traces import SegmentSource +from sentry_sdk.traces import SegmentNameSource from tests.conftest import TestTransport @@ -240,8 +240,8 @@ def test_tracing_in_ray_tasks(task_options, task, span_streaming): == f"tests.integrations.ray.test_ray.{task.__name__}" ) assert ( - worker_spans[1]["attributes"]["sentry.span.source"]["value"] - == SegmentSource.TASK + worker_spans[1]["attributes"]["sentry.segment.name.source"]["value"] + == SegmentNameSource.TASK ) span = client_spans[0] diff --git a/tests/integrations/sanic/test_sanic.py b/tests/integrations/sanic/test_sanic.py index 703da52bc1..8f44c8f96b 100644 --- a/tests/integrations/sanic/test_sanic.py +++ b/tests/integrations/sanic/test_sanic.py @@ -466,7 +466,7 @@ def test_transactions( if segment is not None: assert segment["name"] == test_config.expected_transaction_name assert ( - segment["attributes"]["sentry.span.source"] + segment["attributes"]["sentry.segment.name.source"] == test_config.expected_source ) diff --git a/tests/integrations/starlite/test_starlite.py b/tests/integrations/starlite/test_starlite.py index 3b6dc44131..50900da9b3 100644 --- a/tests/integrations/starlite/test_starlite.py +++ b/tests/integrations/starlite/test_starlite.py @@ -160,7 +160,7 @@ def test_transaction_name_and_source( spans = [item.payload for item in items] spans = [span for span in spans if expected_tx_name in span["name"]] assert len(spans) == 1 - assert spans[0]["attributes"]["sentry.span.source"] == "component" + assert spans[0]["attributes"]["sentry.segment.name.source"] == "component" else: events = capture_events() diff --git a/tests/integrations/tornado/test_tornado.py b/tests/integrations/tornado/test_tornado.py index c5b788b289..d969ab44bb 100644 --- a/tests/integrations/tornado/test_tornado.py +++ b/tests/integrations/tornado/test_tornado.py @@ -184,7 +184,7 @@ def test_transactions( else "tests.integrations.tornado.test_tornado.CrashingHandler.post" ) assert server_segment["name"] == expected_handler - assert server_segment["attributes"]["sentry.span.source"] == "component" + assert server_segment["attributes"]["sentry.segment.name.source"] == "component" assert server_segment["attributes"]["http.request.method"] == "POST" assert server_segment["attributes"]["http.request.body.data"] == "heyoo" assert server_segment["attributes"]["http.response.status_code"] == code diff --git a/tests/integrations/wsgi/test_wsgi.py b/tests/integrations/wsgi/test_wsgi.py index 3b684adb0d..314bc64eaa 100644 --- a/tests/integrations/wsgi/test_wsgi.py +++ b/tests/integrations/wsgi/test_wsgi.py @@ -248,7 +248,7 @@ def dogpark(environ, start_response): assert span["is_segment"] is True assert span["name"] == "generic WSGI request" assert span["attributes"]["sentry.op"] == "http.server" - assert span["attributes"]["sentry.span.source"] == "route" + assert span["attributes"]["sentry.segment.name.source"] == "route" assert span["attributes"]["http.request.method"] == "GET" assert span["attributes"]["http.response.status_code"] == 200 assert span["status"] == "ok" From 9ed5d34dfba2511c493ca6a9aa70a21e1b4a4b14 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 17 Jul 2026 11:40:16 +0200 Subject: [PATCH 2/6] fix wrong enum in celery integration --- sentry_sdk/integrations/celery/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index 21ef36f152..b03a974513 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -18,6 +18,7 @@ from sentry_sdk.scope import Scope, should_send_default_pii from sentry_sdk.traces import StreamedSpan, get_current_span from sentry_sdk.tracing import BAGGAGE_HEADER_NAME, Span, TransactionSource +from sentry_sdk.tracing import SegmentNameSource from sentry_sdk.tracing_utils import Baggage, has_span_streaming_enabled from sentry_sdk.utils import ( SENSITIVE_DATA_SUBSTITUTE, @@ -361,7 +362,7 @@ def _inner(*args: "Any", **kwargs: "Any") -> "Any": parent_span=None, # make this a segment attributes={ "sentry.origin": CeleryIntegration.origin, - "sentry.segment.name.source": TransactionSource.TASK.value, + "sentry.segment.name.source": SegmentNameSource.TASK.value, "sentry.op": OP.QUEUE_TASK_CELERY, }, ) From 3fa0d31229e7816429ee546221a713047ededc9c Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 17 Jul 2026 11:43:54 +0200 Subject: [PATCH 3/6] fix import --- sentry_sdk/integrations/celery/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index b03a974513..dcbc158dc3 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -16,9 +16,8 @@ from sentry_sdk.integrations.celery.utils import _now_seconds_since_epoch from sentry_sdk.integrations.logging import ignore_logger from sentry_sdk.scope import Scope, should_send_default_pii -from sentry_sdk.traces import StreamedSpan, get_current_span +from sentry_sdk.traces import StreamedSpan, get_current_span, SegmentNameSource from sentry_sdk.tracing import BAGGAGE_HEADER_NAME, Span, TransactionSource -from sentry_sdk.tracing import SegmentNameSource from sentry_sdk.tracing_utils import Baggage, has_span_streaming_enabled from sentry_sdk.utils import ( SENSITIVE_DATA_SUBSTITUTE, From dc182a848f8402ea282332dba969ad22df229183 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 17 Jul 2026 13:51:46 +0200 Subject: [PATCH 4/6] fix lint --- sentry_sdk/integrations/celery/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index dcbc158dc3..be40c71131 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -16,7 +16,7 @@ from sentry_sdk.integrations.celery.utils import _now_seconds_since_epoch from sentry_sdk.integrations.logging import ignore_logger from sentry_sdk.scope import Scope, should_send_default_pii -from sentry_sdk.traces import StreamedSpan, get_current_span, SegmentNameSource +from sentry_sdk.traces import SegmentNameSource, StreamedSpan, get_current_span from sentry_sdk.tracing import BAGGAGE_HEADER_NAME, Span, TransactionSource from sentry_sdk.tracing_utils import Baggage, has_span_streaming_enabled from sentry_sdk.utils import ( From 7b5a029ae01321b5ebf996983e4afdba8b7c546f Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 17 Jul 2026 15:08:33 +0200 Subject: [PATCH 5/6] Apply suggestion from @ericapisani Co-authored-by: Erica Pisani --- sentry_sdk/traces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/traces.py b/sentry_sdk/traces.py index 560b4e726a..cbf650a265 100644 --- a/sentry_sdk/traces.py +++ b/sentry_sdk/traces.py @@ -65,7 +65,7 @@ def __str__(self) -> str: _VALID_SPAN_STATUSES = frozenset(e.value for e in SpanStatus) -# Segment name source, see +# The source of a segment name, see # https://getsentry.github.io/sentry-conventions/attributes/sentry/#sentry-segment-name-source class SegmentNameSource(str, Enum): COMPONENT = "component" From 53d2345707ccab08a7e5983f9256cd475c505514 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 17 Jul 2026 15:08:43 +0200 Subject: [PATCH 6/6] remove useless assertions --- tests/integrations/aiohttp/test_aiohttp.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integrations/aiohttp/test_aiohttp.py b/tests/integrations/aiohttp/test_aiohttp.py index e21971218c..895bb59d93 100644 --- a/tests/integrations/aiohttp/test_aiohttp.py +++ b/tests/integrations/aiohttp/test_aiohttp.py @@ -1611,8 +1611,6 @@ async def hello(request): assert server_span["attributes"]["sentry.segment.name.source"] == "component" assert "sentry.segment.name.source" not in child_span["attributes"] - assert "sentry.span.source" not in server_span["attributes"] - assert "sentry.span.source" not in child_span["attributes"] if send_default_pii: assert server_span["attributes"]["user.ip_address"] == "127.0.0.1"