Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 36d60de

Browse filesBrowse files
committed
Cleanup origin handling and defaults
1 parent 5ccfb34 commit 36d60de
Copy full SHA for 36d60de

File tree

Expand file treeCollapse file tree

7 files changed

+19
-18
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+19
-18
lines changed

‎sentry_sdk/api.py

Copy file name to clipboardExpand all lines: sentry_sdk/api.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,8 @@ def get_baggage():
336336
return None
337337

338338

339-
def continue_trace(
340-
environ_or_headers, op=None, name=None, source=None, origin="manual"
341-
):
342-
# type: (Dict[str, Any], Optional[str], Optional[str], Optional[str], str) -> Transaction
339+
def continue_trace(environ_or_headers, op=None, name=None, source=None, origin=None):
340+
# type: (Dict[str, Any], Optional[str], Optional[str], Optional[str], Optional[str]) -> Transaction
343341
"""
344342
Sets the propagation context from environment or headers and returns a transaction.
345343
"""

‎sentry_sdk/integrations/asgi.py

Copy file name to clipboardExpand all lines: sentry_sdk/integrations/asgi.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ def __init__(
9696
unsafe_context_data=False,
9797
transaction_style="endpoint",
9898
mechanism_type="asgi",
99-
span_origin="manual",
99+
span_origin=None,
100100
):
101-
# type: (Any, bool, str, str, str) -> None
101+
# type: (Any, bool, str, str, Optional[str]) -> None
102102
"""
103103
Instrument an ASGI application with Sentry. Provides HTTP/websocket
104104
data to sent events and basic handling for exceptions bubbling up

‎sentry_sdk/integrations/opentelemetry/potel_span_processor.py

Copy file name to clipboardExpand all lines: sentry_sdk/integrations/opentelemetry/potel_span_processor.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
from opentelemetry.sdk.trace import Span, ReadableSpan, SpanProcessor
66

77
from sentry_sdk import capture_event
8+
from sentry_sdk.tracing import DEFAULT_SPAN_ORIGIN
89
from sentry_sdk.integrations.opentelemetry.utils import (
910
is_sentry_span,
1011
convert_from_otel_timestamp,
1112
extract_span_data,
1213
)
1314
from sentry_sdk.integrations.opentelemetry.consts import (
1415
OTEL_SENTRY_CONTEXT,
15-
SPAN_ORIGIN,
1616
)
1717
from sentry_sdk._types import TYPE_CHECKING
1818

@@ -121,7 +121,7 @@ def _root_span_to_transaction_event(self, span):
121121
trace_context = {
122122
"trace_id": trace_id,
123123
"span_id": span_id,
124-
"origin": origin,
124+
"origin": origin or DEFAULT_SPAN_ORIGIN,
125125
"op": op,
126126
"status": status,
127127
} # type: dict[str, Any]
@@ -170,7 +170,7 @@ def _span_to_json(self, span):
170170
"status": status,
171171
"start_timestamp": convert_from_otel_timestamp(span.start_time),
172172
"timestamp": convert_from_otel_timestamp(span.end_time),
173-
"origin": origin or SPAN_ORIGIN,
173+
"origin": origin or DEFAULT_SPAN_ORIGIN,
174174
} # type: dict[str, Any]
175175

176176
if parent_span_id:

‎sentry_sdk/integrations/wsgi.py

Copy file name to clipboardExpand all lines: sentry_sdk/integrations/wsgi.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def get_request_url(environ, use_x_forwarded_for=False):
6767
class SentryWsgiMiddleware:
6868
__slots__ = ("app", "use_x_forwarded_for", "span_origin")
6969

70-
def __init__(self, app, use_x_forwarded_for=False, span_origin="manual"):
71-
# type: (Callable[[Dict[str, str], Callable[..., Any]], Any], bool, str) -> None
70+
def __init__(self, app, use_x_forwarded_for=False, span_origin=None):
71+
# type: (Callable[[Dict[str, str], Callable[..., Any]], Any], bool, Optional[str]) -> None
7272
self.app = app
7373
self.use_x_forwarded_for = use_x_forwarded_for
7474
self.span_origin = span_origin

‎sentry_sdk/scope.py

Copy file name to clipboardExpand all lines: sentry_sdk/scope.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,9 @@ def start_span(self, span=None, custom_sampling_context=None, **kwargs):
10561056
return span
10571057

10581058
def continue_trace(
1059-
self, environ_or_headers, op=None, name=None, source=None, origin="manual"
1059+
self, environ_or_headers, op=None, name=None, source=None, origin=None
10601060
):
1061-
# type: (Dict[str, Any], Optional[str], Optional[str], Optional[str], str) -> Transaction
1061+
# type: (Dict[str, Any], Optional[str], Optional[str], Optional[str], Optional[str]) -> Transaction
10621062
"""
10631063
Sets the propagation context from environment or headers and returns a transaction.
10641064
"""

‎sentry_sdk/tracing.py

Copy file name to clipboardExpand all lines: sentry_sdk/tracing.py
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ class TransactionKwargs(SpanKwargs, total=False):
153153
"url": TRANSACTION_SOURCE_ROUTE,
154154
}
155155

156+
DEFAULT_SPAN_ORIGIN = "manual"
157+
156158
tracer = otel_trace.get_tracer(__name__)
157159

158160

@@ -282,7 +284,7 @@ def __init__(
282284
containing_transaction=None, # type: Optional[Transaction]
283285
start_timestamp=None, # type: Optional[Union[datetime, float]]
284286
scope=None, # type: Optional[sentry_sdk.Scope]
285-
origin="manual", # type: str
287+
origin=None, # type: Optional[str]
286288
):
287289
# type: (...) -> None
288290
self.trace_id = trace_id or uuid.uuid4().hex
@@ -295,7 +297,7 @@ def __init__(
295297
self.status = status
296298
self.hub = hub # backwards compatibility
297299
self.scope = scope
298-
self.origin = origin
300+
self.origin = origin or DEFAULT_SPAN_ORIGIN
299301
self._measurements = {} # type: Dict[str, MeasurementValue]
300302
self._tags = {} # type: MutableMapping[str, str]
301303
self._data = {} # type: Dict[str, Any]
@@ -1266,7 +1268,7 @@ def __init__(
12661268
status=None, # type: Optional[str]
12671269
scope=None, # type: Optional[Scope]
12681270
start_timestamp=None, # type: Optional[Union[datetime, float]]
1269-
origin="manual", # type: str
1271+
origin=None, # type: Optional[str]
12701272
**_, # type: dict[str, object]
12711273
):
12721274
# type: (...) -> None
@@ -1290,7 +1292,8 @@ def __init__(
12901292
) # XXX
12911293
self._active = active
12921294

1293-
self._otel_span.set_attribute(SentrySpanAttribute.ORIGIN, origin)
1295+
if origin:
1296+
self._otel_span.set_attribute(SentrySpanAttribute.ORIGIN, origin)
12941297
self.op = op
12951298
self.description = description
12961299
if status is not None:

‎sentry_sdk/tracing_utils.py

Copy file name to clipboardExpand all lines: sentry_sdk/tracing_utils.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def record_sql_queries(
112112
paramstyle, # type: Optional[str]
113113
executemany, # type: bool
114114
record_cursor_repr=False, # type: bool
115-
span_origin="manual", # type: str
115+
span_origin=None, # type: Optional[str]
116116
):
117117
# type: (...) -> Generator[sentry_sdk.tracing.Span, None, None]
118118

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.