Skip to content

Commit e6ca5a2

Browse files
authored
Remove usages of deprecated description and replace by name in start_span() calls. (getsentry#3525)
Replace the deprecated `description` parameter in all calls to `start_span()` and `start_child` and replace it with the new `name` parameter.
1 parent b1b16b0 commit e6ca5a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+98
-100
lines changed

sentry_sdk/ai/monitoring.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def sync_wrapped(*args, **kwargs):
3333
curr_pipeline = _ai_pipeline_name.get()
3434
op = span_kwargs.get("op", "ai.run" if curr_pipeline else "ai.pipeline")
3535

36-
with start_span(description=description, op=op, **span_kwargs) as span:
36+
with start_span(name=description, op=op, **span_kwargs) as span:
3737
for k, v in kwargs.pop("sentry_tags", {}).items():
3838
span.set_tag(k, v)
3939
for k, v in kwargs.pop("sentry_data", {}).items():
@@ -62,7 +62,7 @@ async def async_wrapped(*args, **kwargs):
6262
curr_pipeline = _ai_pipeline_name.get()
6363
op = span_kwargs.get("op", "ai.run" if curr_pipeline else "ai.pipeline")
6464

65-
with start_span(description=description, op=op, **span_kwargs) as span:
65+
with start_span(name=description, op=op, **span_kwargs) as span:
6666
for k, v in kwargs.pop("sentry_tags", {}).items():
6767
span.set_tag(k, v)
6868
for k, v in kwargs.pop("sentry_data", {}).items():

sentry_sdk/integrations/aiohttp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ async def on_request_start(session, trace_config_ctx, params):
205205

206206
span = sentry_sdk.start_span(
207207
op=OP.HTTP_CLIENT,
208-
description="%s %s"
208+
name="%s %s"
209209
% (method, parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE),
210210
origin=AioHttpIntegration.origin,
211211
)

sentry_sdk/integrations/anthropic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _sentry_patched_create(*args, **kwargs):
9494

9595
span = sentry_sdk.start_span(
9696
op=OP.ANTHROPIC_MESSAGES_CREATE,
97-
description="Anthropic messages create",
97+
name="Anthropic messages create",
9898
origin=AnthropicIntegration.origin,
9999
)
100100
span.__enter__()

sentry_sdk/integrations/arq.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async def _sentry_enqueue_job(self, function, *args, **kwargs):
7979
return await old_enqueue_job(self, function, *args, **kwargs)
8080

8181
with sentry_sdk.start_span(
82-
op=OP.QUEUE_SUBMIT_ARQ, description=function, origin=ArqIntegration.origin
82+
op=OP.QUEUE_SUBMIT_ARQ, name=function, origin=ArqIntegration.origin
8383
):
8484
return await old_enqueue_job(self, function, *args, **kwargs)
8585

sentry_sdk/integrations/asyncio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def _coro_creating_hub_and_span():
4646
with sentry_sdk.isolation_scope():
4747
with sentry_sdk.start_span(
4848
op=OP.FUNCTION,
49-
description=get_name(coro),
49+
name=get_name(coro),
5050
origin=AsyncioIntegration.origin,
5151
):
5252
try:

sentry_sdk/integrations/asyncpg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ async def _inner(*args: Any, **kwargs: Any) -> T:
165165

166166
with sentry_sdk.start_span(
167167
op=OP.DB,
168-
description="connect",
168+
name="connect",
169169
origin=AsyncPGIntegration.origin,
170170
) as span:
171171
span.set_data(SPANDATA.DB_SYSTEM, "postgresql")

sentry_sdk/integrations/boto3.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _sentry_request_created(service_id, request, operation_name, **kwargs):
6969
description = "aws.%s.%s" % (service_id, operation_name)
7070
span = sentry_sdk.start_span(
7171
op=OP.HTTP_CLIENT,
72-
description=description,
72+
name=description,
7373
origin=Boto3Integration.origin,
7474
)
7575

@@ -107,7 +107,7 @@ def _sentry_after_call(context, parsed, **kwargs):
107107

108108
streaming_span = span.start_child(
109109
op=OP.HTTP_CLIENT_STREAM,
110-
description=span.description,
110+
name=span.description,
111111
origin=Boto3Integration.origin,
112112
)
113113

sentry_sdk/integrations/celery/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def apply_async(*args, **kwargs):
274274
span_mgr = (
275275
sentry_sdk.start_span(
276276
op=OP.QUEUE_SUBMIT_CELERY,
277-
description=task_name,
277+
name=task_name,
278278
origin=CeleryIntegration.origin,
279279
)
280280
if not task_started_from_beat
@@ -374,7 +374,7 @@ def _inner(*args, **kwargs):
374374
try:
375375
with sentry_sdk.start_span(
376376
op=OP.QUEUE_PROCESS,
377-
description=task.name,
377+
name=task.name,
378378
origin=CeleryIntegration.origin,
379379
) as span:
380380
_set_messaging_destination_name(task, span)
@@ -503,7 +503,7 @@ def sentry_publish(self, *args, **kwargs):
503503

504504
with sentry_sdk.start_span(
505505
op=OP.QUEUE_PUBLISH,
506-
description=task_name,
506+
name=task_name,
507507
origin=CeleryIntegration.origin,
508508
) as span:
509509
if task_id is not None:

sentry_sdk/integrations/clickhouse_driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def _inner(*args: P.args, **kwargs: P.kwargs) -> T:
8383

8484
span = sentry_sdk.start_span(
8585
op=OP.DB,
86-
description=query,
86+
name=query,
8787
origin=ClickhouseDriverIntegration.origin,
8888
)
8989

sentry_sdk/integrations/cohere.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def new_chat(*args, **kwargs):
142142

143143
span = sentry_sdk.start_span(
144144
op=consts.OP.COHERE_CHAT_COMPLETIONS_CREATE,
145-
description="cohere.client.Chat",
145+
name="cohere.client.Chat",
146146
origin=CohereIntegration.origin,
147147
)
148148
span.__enter__()
@@ -227,7 +227,7 @@ def new_embed(*args, **kwargs):
227227
# type: (*Any, **Any) -> Any
228228
with sentry_sdk.start_span(
229229
op=consts.OP.COHERE_EMBEDDINGS_CREATE,
230-
description="Cohere Embedding Creation",
230+
name="Cohere Embedding Creation",
231231
origin=CohereIntegration.origin,
232232
) as span:
233233
integration = sentry_sdk.get_client().get_integration(CohereIntegration)

sentry_sdk/integrations/django/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ def connect(self):
683683

684684
with sentry_sdk.start_span(
685685
op=OP.DB,
686-
description="connect",
686+
name="connect",
687687
origin=DjangoIntegration.origin_db,
688688
) as span:
689689
_set_db_data(span, self)

sentry_sdk/integrations/django/asgi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async def sentry_wrapped_callback(request, *args, **kwargs):
174174

175175
with sentry_sdk.start_span(
176176
op=OP.VIEW_RENDER,
177-
description=request.resolver_match.view_name,
177+
name=request.resolver_match.view_name,
178178
origin=DjangoIntegration.origin,
179179
):
180180
return await callback(request, *args, **kwargs)

sentry_sdk/integrations/django/caching.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _instrument_call(
5252

5353
with sentry_sdk.start_span(
5454
op=op,
55-
description=description,
55+
name=description,
5656
origin=DjangoIntegration.origin,
5757
) as span:
5858
value = original_method(*args, **kwargs)

sentry_sdk/integrations/django/middleware.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def _check_middleware_span(old_method):
8787

8888
middleware_span = sentry_sdk.start_span(
8989
op=OP.MIDDLEWARE_DJANGO,
90-
description=description,
90+
name=description,
9191
origin=DjangoIntegration.origin,
9292
)
9393
middleware_span.set_tag("django.function_name", function_name)

sentry_sdk/integrations/django/signals_handlers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def wrapper(*args, **kwargs):
6666
signal_name = _get_receiver_name(receiver)
6767
with sentry_sdk.start_span(
6868
op=OP.EVENT_DJANGO,
69-
description=signal_name,
69+
name=signal_name,
7070
origin=DjangoIntegration.origin,
7171
) as span:
7272
span.set_data("signal", signal_name)

sentry_sdk/integrations/django/templates.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def rendered_content(self):
7070
# type: (SimpleTemplateResponse) -> str
7171
with sentry_sdk.start_span(
7272
op=OP.TEMPLATE_RENDER,
73-
description=_get_template_name_description(self.template_name),
73+
name=_get_template_name_description(self.template_name),
7474
origin=DjangoIntegration.origin,
7575
) as span:
7676
span.set_data("context", self.context_data)
@@ -98,7 +98,7 @@ def render(request, template_name, context=None, *args, **kwargs):
9898

9999
with sentry_sdk.start_span(
100100
op=OP.TEMPLATE_RENDER,
101-
description=_get_template_name_description(template_name),
101+
name=_get_template_name_description(template_name),
102102
origin=DjangoIntegration.origin,
103103
) as span:
104104
span.set_data("context", context)

sentry_sdk/integrations/django/views.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def sentry_patched_render(self):
3535
# type: (SimpleTemplateResponse) -> Any
3636
with sentry_sdk.start_span(
3737
op=OP.VIEW_RESPONSE_RENDER,
38-
description="serialize response",
38+
name="serialize response",
3939
origin=DjangoIntegration.origin,
4040
):
4141
return old_render(self)
@@ -84,7 +84,7 @@ def sentry_wrapped_callback(request, *args, **kwargs):
8484

8585
with sentry_sdk.start_span(
8686
op=OP.VIEW_RENDER,
87-
description=request.resolver_match.view_name,
87+
name=request.resolver_match.view_name,
8888
origin=DjangoIntegration.origin,
8989
):
9090
return callback(request, *args, **kwargs)

sentry_sdk/integrations/graphene.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ def graphql_span(schema, source, kwargs):
142142

143143
scope = sentry_sdk.get_current_scope()
144144
if scope.span:
145-
_graphql_span = scope.span.start_child(op=op, description=operation_name)
145+
_graphql_span = scope.span.start_child(op=op, name=operation_name)
146146
else:
147-
_graphql_span = sentry_sdk.start_span(op=op, description=operation_name)
147+
_graphql_span = sentry_sdk.start_span(op=op, name=operation_name)
148148

149149
_graphql_span.set_data("graphql.document", source)
150150
_graphql_span.set_data("graphql.operation.name", operation_name)

sentry_sdk/integrations/grpc/aio/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def intercept_unary_unary(
5050

5151
with sentry_sdk.start_span(
5252
op=OP.GRPC_CLIENT,
53-
description="unary unary call to %s" % method.decode(),
53+
name="unary unary call to %s" % method.decode(),
5454
origin=SPAN_ORIGIN,
5555
) as span:
5656
span.set_data("type", "unary unary")
@@ -80,7 +80,7 @@ async def intercept_unary_stream(
8080

8181
with sentry_sdk.start_span(
8282
op=OP.GRPC_CLIENT,
83-
description="unary stream call to %s" % method.decode(),
83+
name="unary stream call to %s" % method.decode(),
8484
origin=SPAN_ORIGIN,
8585
) as span:
8686
span.set_data("type", "unary stream")

sentry_sdk/integrations/grpc/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def intercept_unary_unary(self, continuation, client_call_details, request):
2929

3030
with sentry_sdk.start_span(
3131
op=OP.GRPC_CLIENT,
32-
description="unary unary call to %s" % method,
32+
name="unary unary call to %s" % method,
3333
origin=SPAN_ORIGIN,
3434
) as span:
3535
span.set_data("type", "unary unary")
@@ -50,7 +50,7 @@ def intercept_unary_stream(self, continuation, client_call_details, request):
5050

5151
with sentry_sdk.start_span(
5252
op=OP.GRPC_CLIENT,
53-
description="unary stream call to %s" % method,
53+
name="unary stream call to %s" % method,
5454
origin=SPAN_ORIGIN,
5555
) as span:
5656
span.set_data("type", "unary stream")

sentry_sdk/integrations/httpx.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def send(self, request, **kwargs):
5353

5454
with sentry_sdk.start_span(
5555
op=OP.HTTP_CLIENT,
56-
description="%s %s"
56+
name="%s %s"
5757
% (
5858
request.method,
5959
parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE,
@@ -109,7 +109,7 @@ async def send(self, request, **kwargs):
109109

110110
with sentry_sdk.start_span(
111111
op=OP.HTTP_CLIENT,
112-
description="%s %s"
112+
name="%s %s"
113113
% (
114114
request.method,
115115
parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE,

sentry_sdk/integrations/huey.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _sentry_enqueue(self, task):
5959
# type: (Huey, Task) -> Optional[Union[Result, ResultGroup]]
6060
with sentry_sdk.start_span(
6161
op=OP.QUEUE_SUBMIT_HUEY,
62-
description=task.name,
62+
name=task.name,
6363
origin=HueyIntegration.origin,
6464
):
6565
if not isinstance(task, PeriodicTask):

sentry_sdk/integrations/huggingface_hub.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def new_text_generation(*args, **kwargs):
7373

7474
span = sentry_sdk.start_span(
7575
op=consts.OP.HUGGINGFACE_HUB_CHAT_COMPLETIONS_CREATE,
76-
description="Text Generation",
76+
name="Text Generation",
7777
origin=HuggingfaceHubIntegration.origin,
7878
)
7979
span.__enter__()

sentry_sdk/integrations/langchain.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def _create_span(self, run_id, parent_id, **kwargs):
146146
watched_span = WatchedSpan(sentry_sdk.start_span(**kwargs))
147147

148148
if kwargs.get("op", "").startswith("ai.pipeline."):
149-
if kwargs.get("description"):
150-
set_ai_pipeline_name(kwargs.get("description"))
149+
if kwargs.get("name"):
150+
set_ai_pipeline_name(kwargs.get("name"))
151151
watched_span.is_pipeline = True
152152

153153
watched_span.span.__enter__()
@@ -186,7 +186,7 @@ def on_llm_start(
186186
run_id,
187187
kwargs.get("parent_run_id"),
188188
op=OP.LANGCHAIN_RUN,
189-
description=kwargs.get("name") or "Langchain LLM call",
189+
name=kwargs.get("name") or "Langchain LLM call",
190190
origin=LangchainIntegration.origin,
191191
)
192192
span = watched_span.span
@@ -208,7 +208,7 @@ def on_chat_model_start(self, serialized, messages, *, run_id, **kwargs):
208208
run_id,
209209
kwargs.get("parent_run_id"),
210210
op=OP.LANGCHAIN_CHAT_COMPLETIONS_CREATE,
211-
description=kwargs.get("name") or "Langchain Chat Model",
211+
name=kwargs.get("name") or "Langchain Chat Model",
212212
origin=LangchainIntegration.origin,
213213
)
214214
span = watched_span.span
@@ -312,7 +312,7 @@ def on_chain_start(self, serialized, inputs, *, run_id, **kwargs):
312312
if kwargs.get("parent_run_id") is not None
313313
else OP.LANGCHAIN_PIPELINE
314314
),
315-
description=kwargs.get("name") or "Chain execution",
315+
name=kwargs.get("name") or "Chain execution",
316316
origin=LangchainIntegration.origin,
317317
)
318318
metadata = kwargs.get("metadata")
@@ -345,7 +345,7 @@ def on_agent_action(self, action, *, run_id, **kwargs):
345345
run_id,
346346
kwargs.get("parent_run_id"),
347347
op=OP.LANGCHAIN_AGENT,
348-
description=action.tool or "AI tool usage",
348+
name=action.tool or "AI tool usage",
349349
origin=LangchainIntegration.origin,
350350
)
351351
if action.tool_input and should_send_default_pii() and self.include_prompts:
@@ -378,9 +378,7 @@ def on_tool_start(self, serialized, input_str, *, run_id, **kwargs):
378378
run_id,
379379
kwargs.get("parent_run_id"),
380380
op=OP.LANGCHAIN_TOOL,
381-
description=serialized.get("name")
382-
or kwargs.get("name")
383-
or "AI tool usage",
381+
name=serialized.get("name") or kwargs.get("name") or "AI tool usage",
384382
origin=LangchainIntegration.origin,
385383
)
386384
if should_send_default_pii() and self.include_prompts:

sentry_sdk/integrations/litestar.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ async def _create_span_call(self, scope, receive, send):
139139
middleware_name = self.__class__.__name__
140140
with sentry_sdk.start_span(
141141
op=OP.MIDDLEWARE_LITESTAR,
142-
description=middleware_name,
142+
name=middleware_name,
143143
origin=LitestarIntegration.origin,
144144
) as middleware_span:
145145
middleware_span.set_tag("litestar.middleware_name", middleware_name)
@@ -151,7 +151,7 @@ async def _sentry_receive(*args, **kwargs):
151151
return await receive(*args, **kwargs)
152152
with sentry_sdk.start_span(
153153
op=OP.MIDDLEWARE_LITESTAR_RECEIVE,
154-
description=getattr(receive, "__qualname__", str(receive)),
154+
name=getattr(receive, "__qualname__", str(receive)),
155155
origin=LitestarIntegration.origin,
156156
) as span:
157157
span.set_tag("litestar.middleware_name", middleware_name)
@@ -168,7 +168,7 @@ async def _sentry_send(message):
168168
return await send(message)
169169
with sentry_sdk.start_span(
170170
op=OP.MIDDLEWARE_LITESTAR_SEND,
171-
description=getattr(send, "__qualname__", str(send)),
171+
name=getattr(send, "__qualname__", str(send)),
172172
origin=LitestarIntegration.origin,
173173
) as span:
174174
span.set_tag("litestar.middleware_name", middleware_name)

0 commit comments

Comments
 (0)