Skip to content

Commit 88cfd8b

Browse files
committed
remove op, origin, source setters
1 parent 8a59428 commit 88cfd8b

15 files changed

Lines changed: 80 additions & 87 deletions

sentry_sdk/integrations/asgi.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,22 @@ async def _run_app(
227227
segment = sentry_sdk.traces.start_span(
228228
name=transaction_name
229229
)
230-
segment.set_op(f"{ty}.server")
230+
segment.set_attribute("sentry.op", f"{ty}.server")
231231
else:
232232
sentry_sdk.traces.new_trace()
233233
segment = sentry_sdk.traces.start_span(
234234
name=transaction_name,
235235
)
236-
segment.set_op(OP.HTTP_SERVER)
236+
segment.set_attribute("sentry.op", OP.HTTP_SERVER)
237237

238238
if segment is not None:
239-
segment.set_source(transaction_source)
240-
segment.set_origin(self.span_origin)
239+
segment.set_attribute(
240+
"sentry.span.source",
241+
getattr(
242+
transaction_source, "value", transaction_source
243+
),
244+
)
245+
segment.set_attribute("sentry.origin", self.span_origin)
241246
segment.set_attribute("asgi.type", ty)
242247

243248
span_ctx = segment or nullcontext()

sentry_sdk/integrations/celery/__init__.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ def apply_async(*args: "Any", **kwargs: "Any") -> "Any":
281281
if span_streaming:
282282
if not task_started_from_beat:
283283
span_mgr = sentry_sdk.traces.start_span(name=task_name)
284-
span_mgr.set_op(OP.QUEUE_SUBMIT_CELERY)
285-
span_mgr.set_origin(CeleryIntegration.origin)
284+
span_mgr.set_attribute("sentry.op", OP.QUEUE_SUBMIT_CELERY)
285+
span_mgr.set_attribute("sentry.origin", CeleryIntegration.origin)
286286
else:
287287
if not task_started_from_beat:
288288
span_mgr = sentry_sdk.start_span(
@@ -330,9 +330,11 @@ def _inner(*args: "Any", **kwargs: "Any") -> "Any":
330330
if span_streaming:
331331
sentry_sdk.traces.continue_trace(headers)
332332
transaction = sentry_sdk.traces.start_span(name=task.name)
333-
transaction.set_origin(CeleryIntegration.origin)
334-
transaction.set_source(TransactionSource.TASK)
335-
transaction.set_op(OP.QUEUE_TASK_CELERY)
333+
transaction.set_attribute("sentry.origin", CeleryIntegration.origin)
334+
transaction.set_attribute(
335+
"sentry.span.source", TransactionSource.TASK.value
336+
)
337+
transaction.set_attribute("sentry.op", OP.QUEUE_TASK_CELERY)
336338

337339
span_ctx = transaction
338340

@@ -401,8 +403,8 @@ def _inner(*args: "Any", **kwargs: "Any") -> "Any":
401403
span: "Union[Span, StreamedSpan]"
402404
if span_streaming:
403405
span = sentry_sdk.traces.start_span(name=task.name)
404-
span.set_op(OP.QUEUE_PROCESS)
405-
span.set_origin(CeleryIntegration.origin)
406+
span.set_attribute("sentry.op", OP.QUEUE_PROCESS)
407+
span.set_attribute("sentry.origin", CeleryIntegration.origin)
406408
else:
407409
span = sentry_sdk.start_span(
408410
op=OP.QUEUE_PROCESS,
@@ -547,8 +549,8 @@ def sentry_publish(self: "Producer", *args: "Any", **kwargs: "Any") -> "Any":
547549
span: "Union[StreamedSpan, Span]"
548550
if span_streaming:
549551
span = sentry_sdk.traces.start_span(name=task_name)
550-
span.set_op(OP.QUEUE_PUBLISH)
551-
span.set_origin(CeleryIntegration.origin)
552+
span.set_attribute("sentry.op", OP.QUEUE_PUBLISH)
553+
span.set_attribute("sentry.origin", CeleryIntegration.origin)
552554
else:
553555
span = sentry_sdk.start_span(
554556
op=OP.QUEUE_PUBLISH,

sentry_sdk/integrations/graphene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def graphql_span(
150150
_graphql_span: "Union[Span, StreamedSpan]"
151151
if span_streaming:
152152
_graphql_span = sentry_sdk.traces.start_span(name=operation_name or "operation")
153-
_graphql_span.set_op(op)
153+
_graphql_span.set_attribute("sentry.op", op)
154154
_graphql_span.set_attribute("graphql.document", source)
155155
if operation_name:
156156
_graphql_span.set_attribute("graphql.operation.name", operation_name)

sentry_sdk/integrations/httpx.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def send(self: "Client", request: "Request", **kwargs: "Any") -> "Response":
7878

7979
with span_ctx as span:
8080
if isinstance(span, StreamedSpan):
81-
span.set_op(OP.HTTP_CLIENT)
82-
span.set_origin(HttpxIntegration.origin)
81+
span.set_attribute("sentry.op", OP.HTTP_CLIENT)
82+
span.set_attribute("sentry.origin", HttpxIntegration.origin)
8383

8484
span.set_attribute(SPANDATA.HTTP_METHOD, request.method)
8585
if parsed_url is not None:
@@ -159,8 +159,8 @@ async def send(
159159

160160
with span_ctx as span:
161161
if isinstance(span, StreamedSpan):
162-
span.set_op(OP.HTTP_CLIENT)
163-
span.set_origin(HttpxIntegration.origin)
162+
span.set_attribute("sentry.op", OP.HTTP_CLIENT)
163+
span.set_attribute("sentry.origin", HttpxIntegration.origin)
164164
span.set_attribute(SPANDATA.HTTP_METHOD, request.method)
165165
if parsed_url is not None:
166166
span.set_attribute("url", parsed_url.url)

sentry_sdk/integrations/huggingface_hub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def new_huggingface_task(*args: "Any", **kwargs: "Any") -> "Any":
9494
span: "Union[StreamedSpan, Span]"
9595
if span_streaming:
9696
span = sentry_sdk.traces.start_span(name=f"{operation_name} {model}")
97-
span.set_op(op)
98-
span.set_origin(HuggingfaceHubIntegration.origin)
97+
span.set_attribute("sentry.op", op)
98+
span.set_attribute("sentry.origin", HuggingfaceHubIntegration.origin)
9999
else:
100100
span = sentry_sdk.start_span(
101101
op=op,

sentry_sdk/integrations/redis/_async_common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ async def _sentry_execute(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
4444
span: "Union[Span, StreamedSpan]"
4545
if span_streaming:
4646
span = sentry_sdk.traces.start_span(name="redis.pipeline.execute")
47-
span.set_origin(SPAN_ORIGIN)
48-
span.set_op(OP.DB_REDIS)
47+
span.set_attribute("sentry.origin", SPAN_ORIGIN)
48+
span.set_attribute("sentry.op", OP.DB_REDIS)
4949
else:
5050
span = sentry_sdk.start_span(
5151
op=OP.DB_REDIS,
@@ -109,8 +109,8 @@ async def _sentry_execute_command(
109109
cache_span = sentry_sdk.traces.start_span(
110110
name=cache_properties["description"]
111111
)
112-
cache_span.set_op(cache_properties["op"])
113-
cache_span.set_origin(SPAN_ORIGIN)
112+
cache_span.set_attribute("sentry.op", cache_properties["op"])
113+
cache_span.set_attribute("sentry.origin", SPAN_ORIGIN)
114114
else:
115115
cache_span = sentry_sdk.start_span(
116116
op=cache_properties["op"],
@@ -124,8 +124,8 @@ async def _sentry_execute_command(
124124
db_span: "Union[Span, StreamedSpan]"
125125
if span_streaming:
126126
db_span = sentry_sdk.traces.start_span(name=db_properties["description"])
127-
db_span.set_op(db_properties["op"])
128-
db_span.set_origin(SPAN_ORIGIN)
127+
db_span.set_attribute("sentry.op", db_properties["op"])
128+
db_span.set_attribute("sentry.origin", SPAN_ORIGIN)
129129
else:
130130
db_span = sentry_sdk.start_span(
131131
op=db_properties["op"],

sentry_sdk/integrations/redis/_sync_common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def sentry_patched_execute(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
4242
span: "Union[Span, StreamedSpan]"
4343
if span_streaming:
4444
span = sentry_sdk.traces.start_span(name="redis.pipeline.execute")
45-
span.set_origin(SPAN_ORIGIN)
46-
span.set_op(OP.DB_REDIS)
45+
span.set_attribute("sentry.origin", SPAN_ORIGIN)
46+
span.set_attribute("sentry.op", OP.DB_REDIS)
4747
else:
4848
span = sentry_sdk.start_span(
4949
op=OP.DB_REDIS,
@@ -109,8 +109,8 @@ def sentry_patched_execute_command(
109109
cache_span = sentry_sdk.traces.start_span(
110110
name=cache_properties["description"]
111111
)
112-
cache_span.set_op(cache_properties["op"])
113-
cache_span.set_origin(SPAN_ORIGIN)
112+
cache_span.set_attribute("sentry.op", cache_properties["op"])
113+
cache_span.set_attribute("sentry.origin", SPAN_ORIGIN)
114114
else:
115115
cache_span = sentry_sdk.start_span(
116116
op=cache_properties["op"],
@@ -124,8 +124,8 @@ def sentry_patched_execute_command(
124124
db_span: "Union[Span, StreamedSpan]"
125125
if span_streaming:
126126
db_span = sentry_sdk.traces.start_span(name=db_properties["description"])
127-
db_span.set_op(db_properties["op"])
128-
db_span.set_origin(SPAN_ORIGIN)
127+
db_span.set_attribute("sentry.op", db_properties["op"])
128+
db_span.set_attribute("sentry.origin", SPAN_ORIGIN)
129129
else:
130130
db_span = sentry_sdk.start_span(
131131
op=db_properties["op"],

sentry_sdk/integrations/rust_tracing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ def on_new_span(self, attrs: str, span_id: str) -> "TraceState":
216216
sentry_span = sentry_sdk.traces.start_span(
217217
name=sentry_span_name, parent_span=parent_sentry_span
218218
)
219-
sentry_span.set_op("function")
220-
sentry_span.set_origin(self.origin)
219+
sentry_span.set_attribute("sentry.op", "function")
220+
sentry_span.set_attribute("sentry.origin", self.origin)
221221
sentry_span.start()
222222
else:
223223
sentry_span = parent_sentry_span.start_child(
@@ -232,8 +232,8 @@ def on_new_span(self, attrs: str, span_id: str) -> "TraceState":
232232
sentry_span = sentry_sdk.traces.start_span(
233233
name=sentry_span_name,
234234
)
235-
sentry_span.set_op("function")
236-
sentry_span.set_origin(self.origin)
235+
sentry_span.set_attribute("sentry.op", "function")
236+
sentry_span.set_attribute("sentry.origin", self.origin)
237237
sentry_span.start()
238238
else:
239239
sentry_span = sentry_sdk.start_span(

sentry_sdk/integrations/starlette.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ async def _create_span_call(
174174
middleware_span: "Optional[Union[Span, StreamedSpan]]" = None
175175
if span_streaming:
176176
middleware_span = sentry_sdk.traces.start_span(name=middleware_name)
177-
middleware_span.set_op(OP.MIDDLEWARE_STARLETTE)
178-
middleware_span.set_origin(StarletteIntegration.origin)
177+
middleware_span.set_attribute("sentry.op", OP.MIDDLEWARE_STARLETTE)
178+
middleware_span.set_attribute("sentry.origin", StarletteIntegration.origin)
179179
middleware_span.set_attribute("starlette.middleware_name", middleware_name)
180180
else:
181181
middleware_span = sentry_sdk.start_span(
@@ -193,8 +193,8 @@ async def _sentry_receive(*args: "Any", **kwargs: "Any") -> "Any":
193193
span = sentry_sdk.traces.start_span(
194194
name=getattr(receive, "__qualname__", str(receive)),
195195
)
196-
span.set_origin(StarletteIntegration.origin)
197-
span.set_op(OP.MIDDLEWARE_STARLETTE_RECEIVE)
196+
span.set_attribute("sentry.origin", StarletteIntegration.origin)
197+
span.set_attribute("sentry.op", OP.MIDDLEWARE_STARLETTE_RECEIVE)
198198
span.set_attribute("starlette.middleware_name", middleware_name)
199199
else:
200200
span = sentry_sdk.start_span(
@@ -218,8 +218,8 @@ async def _sentry_send(*args: "Any", **kwargs: "Any") -> "Any":
218218
span = sentry_sdk.traces.start_span(
219219
name=getattr(send, "__qualname__", str(send)),
220220
)
221-
span.set_op(OP.MIDDLEWARE_STARLETTE_SEND)
222-
span.set_origin(StarletteIntegration.origin)
221+
span.set_attribute("sentry.op", OP.MIDDLEWARE_STARLETTE_SEND)
222+
span.set_attribute("sentry.origin", StarletteIntegration.origin)
223223
span.set_attribute("starlette.middleware_name", middleware_name)
224224
else:
225225
span = sentry_sdk.start_span(

sentry_sdk/integrations/stdlib.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ def putrequest(
110110
span = sentry_sdk.traces.start_span(
111111
name=f"{method} {parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE}"
112112
)
113-
span.set_op(OP.HTTP_CLIENT)
114-
span.set_origin("auto.http.stdlib.httplib")
113+
span.set_attribute("sentry.op", OP.HTTP_CLIENT)
114+
span.set_attribute("sentry.origin", "auto.http.stdlib.httplib")
115115

116116
span.set_attribute(SPANDATA.HTTP_METHOD, method)
117117
if parsed_url is not None:
@@ -269,8 +269,8 @@ def sentry_patched_popen_init(
269269
span = sentry_sdk.traces.start_span(
270270
name=description,
271271
)
272-
span.set_op(OP.SUBPROCESS)
273-
span.set_origin("auto.subprocess.stdlib.subprocess")
272+
span.set_attribute("sentry.op", OP.SUBPROCESS)
273+
span.set_attribute("sentry.origin", "auto.subprocess.stdlib.subprocess")
274274
else:
275275
span = sentry_sdk.start_span(
276276
op=OP.SUBPROCESS,
@@ -321,8 +321,8 @@ def sentry_patched_popen_wait(
321321
span: "Optional[Union[Span, StreamedSpan]]" = None
322322
if span_streaming:
323323
span = sentry_sdk.traces.start_span(name="subprocess popen")
324-
span.set_op(OP.SUBPROCESS_WAIT)
325-
span.set_origin("auto.subprocess.stdlib.subprocess")
324+
span.set_attribute("sentry.op", OP.SUBPROCESS_WAIT)
325+
span.set_attribute("sentry.origin", "auto.subprocess.stdlib.subprocess")
326326
span.set_attribute("subprocess.pid", self.pid)
327327
else:
328328
span = sentry_sdk.start_span(
@@ -350,8 +350,8 @@ def sentry_patched_popen_communicate(
350350
span = sentry_sdk.traces.start_span(
351351
name="subprocess communicate",
352352
)
353-
span.set_op(OP.SUBPROCESS_COMMUNICATE)
354-
span.set_origin("auto.subprocess.stdlib.subprocess")
353+
span.set_attribute("sentry.op", OP.SUBPROCESS_COMMUNICATE)
354+
span.set_attribute("sentry.origin", "auto.subprocess.stdlib.subprocess")
355355
span.set_attribute("subprocess.pid", self.pid)
356356
else:
357357
span = sentry_sdk.start_span(

0 commit comments

Comments
 (0)