Skip to content
Merged
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
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
from sentry_sdk.traces import (
NoOpStreamedSpan,
SegmentSource,
SegmentNameSource,
SpanStatus,
StreamedSpan,
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/arq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 14 additions & 10 deletions sentry_sdk/integrations/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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():
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 (
Expand Down Expand Up @@ -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": SegmentNameSource.TASK.value,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seer pointed out that the "wrong" enum was used here (no big deal as the values were identical). So I changed it over to SegmentNameSource

"sentry.op": OP.QUEUE_TASK_CELERY,
},
)
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/dramatiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/grpc/aio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/grpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/huey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
):
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
},
Comment thread
sentry[bot] marked this conversation as resolved.
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/sanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
)
Expand Down
6 changes: 4 additions & 2 deletions sentry_sdk/integrations/strawberry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions sentry_sdk/integrations/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
},
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading