Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usages of deprecated description and replace by name in start_span() calls. #3525

Merged
merged 5 commits into from
Sep 12, 2024
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
4 changes: 2 additions & 2 deletions sentry_sdk/ai/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def sync_wrapped(*args, **kwargs):
curr_pipeline = _ai_pipeline_name.get()
op = span_kwargs.get("op", "ai.run" if curr_pipeline else "ai.pipeline")

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

with start_span(description=description, op=op, **span_kwargs) as span:
with start_span(name=description, op=op, **span_kwargs) as span:
for k, v in kwargs.pop("sentry_tags", {}).items():
span.set_tag(k, v)
for k, v in kwargs.pop("sentry_data", {}).items():
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async def on_request_start(session, trace_config_ctx, params):

span = sentry_sdk.start_span(
op=OP.HTTP_CLIENT,
description="%s %s"
name="%s %s"
% (method, parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE),
origin=AioHttpIntegration.origin,
)
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _sentry_patched_create(*args, **kwargs):

span = sentry_sdk.start_span(
op=OP.ANTHROPIC_MESSAGES_CREATE,
description="Anthropic messages create",
name="Anthropic messages create",
origin=AnthropicIntegration.origin,
)
span.__enter__()
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/arq.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def _sentry_enqueue_job(self, function, *args, **kwargs):
return await old_enqueue_job(self, function, *args, **kwargs)

with sentry_sdk.start_span(
op=OP.QUEUE_SUBMIT_ARQ, description=function, origin=ArqIntegration.origin
op=OP.QUEUE_SUBMIT_ARQ, name=function, origin=ArqIntegration.origin
):
return await old_enqueue_job(self, function, *args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def _coro_creating_hub_and_span():
with sentry_sdk.isolation_scope():
with sentry_sdk.start_span(
op=OP.FUNCTION,
description=get_name(coro),
name=get_name(coro),
origin=AsyncioIntegration.origin,
):
try:
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/asyncpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async def _inner(*args: Any, **kwargs: Any) -> T:

with sentry_sdk.start_span(
op=OP.DB,
description="connect",
name="connect",
origin=AsyncPGIntegration.origin,
) as span:
span.set_data(SPANDATA.DB_SYSTEM, "postgresql")
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _sentry_request_created(service_id, request, operation_name, **kwargs):
description = "aws.%s.%s" % (service_id, operation_name)
span = sentry_sdk.start_span(
op=OP.HTTP_CLIENT,
description=description,
name=description,
origin=Boto3Integration.origin,
)

Expand Down Expand Up @@ -107,7 +107,7 @@ def _sentry_after_call(context, parsed, **kwargs):

streaming_span = span.start_child(
op=OP.HTTP_CLIENT_STREAM,
description=span.description,
name=span.description,
origin=Boto3Integration.origin,
)

Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def apply_async(*args, **kwargs):
span_mgr = (
sentry_sdk.start_span(
op=OP.QUEUE_SUBMIT_CELERY,
description=task_name,
name=task_name,
origin=CeleryIntegration.origin,
)
if not task_started_from_beat
Expand Down Expand Up @@ -374,7 +374,7 @@ def _inner(*args, **kwargs):
try:
with sentry_sdk.start_span(
op=OP.QUEUE_PROCESS,
description=task.name,
name=task.name,
origin=CeleryIntegration.origin,
) as span:
_set_messaging_destination_name(task, span)
Expand Down Expand Up @@ -503,7 +503,7 @@ def sentry_publish(self, *args, **kwargs):

with sentry_sdk.start_span(
op=OP.QUEUE_PUBLISH,
description=task_name,
name=task_name,
origin=CeleryIntegration.origin,
) as span:
if task_id is not None:
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/clickhouse_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _inner(*args: P.args, **kwargs: P.kwargs) -> T:

span = sentry_sdk.start_span(
op=OP.DB,
description=query,
name=query,
origin=ClickhouseDriverIntegration.origin,
)

Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def new_chat(*args, **kwargs):

span = sentry_sdk.start_span(
op=consts.OP.COHERE_CHAT_COMPLETIONS_CREATE,
description="cohere.client.Chat",
name="cohere.client.Chat",
origin=CohereIntegration.origin,
)
span.__enter__()
Expand Down Expand Up @@ -227,7 +227,7 @@ def new_embed(*args, **kwargs):
# type: (*Any, **Any) -> Any
with sentry_sdk.start_span(
op=consts.OP.COHERE_EMBEDDINGS_CREATE,
description="Cohere Embedding Creation",
name="Cohere Embedding Creation",
origin=CohereIntegration.origin,
) as span:
integration = sentry_sdk.get_client().get_integration(CohereIntegration)
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def connect(self):

with sentry_sdk.start_span(
op=OP.DB,
description="connect",
name="connect",
origin=DjangoIntegration.origin_db,
) as span:
_set_db_data(span, self)
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/django/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async def sentry_wrapped_callback(request, *args, **kwargs):

with sentry_sdk.start_span(
op=OP.VIEW_RENDER,
description=request.resolver_match.view_name,
name=request.resolver_match.view_name,
origin=DjangoIntegration.origin,
):
return await callback(request, *args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/django/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _instrument_call(

with sentry_sdk.start_span(
op=op,
description=description,
name=description,
origin=DjangoIntegration.origin,
) as span:
value = original_method(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _check_middleware_span(old_method):

middleware_span = sentry_sdk.start_span(
op=OP.MIDDLEWARE_DJANGO,
description=description,
name=description,
origin=DjangoIntegration.origin,
)
middleware_span.set_tag("django.function_name", function_name)
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/django/signals_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def wrapper(*args, **kwargs):
signal_name = _get_receiver_name(receiver)
with sentry_sdk.start_span(
op=OP.EVENT_DJANGO,
description=signal_name,
name=signal_name,
origin=DjangoIntegration.origin,
) as span:
span.set_data("signal", signal_name)
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/django/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def rendered_content(self):
# type: (SimpleTemplateResponse) -> str
with sentry_sdk.start_span(
op=OP.TEMPLATE_RENDER,
description=_get_template_name_description(self.template_name),
name=_get_template_name_description(self.template_name),
origin=DjangoIntegration.origin,
) as span:
span.set_data("context", self.context_data)
Expand Down Expand Up @@ -98,7 +98,7 @@ def render(request, template_name, context=None, *args, **kwargs):

with sentry_sdk.start_span(
op=OP.TEMPLATE_RENDER,
description=_get_template_name_description(template_name),
name=_get_template_name_description(template_name),
origin=DjangoIntegration.origin,
) as span:
span.set_data("context", context)
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/django/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def sentry_patched_render(self):
# type: (SimpleTemplateResponse) -> Any
with sentry_sdk.start_span(
op=OP.VIEW_RESPONSE_RENDER,
description="serialize response",
name="serialize response",
origin=DjangoIntegration.origin,
):
return old_render(self)
Expand Down Expand Up @@ -84,7 +84,7 @@ def sentry_wrapped_callback(request, *args, **kwargs):

with sentry_sdk.start_span(
op=OP.VIEW_RENDER,
description=request.resolver_match.view_name,
name=request.resolver_match.view_name,
origin=DjangoIntegration.origin,
):
return callback(request, *args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/graphene.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def graphql_span(schema, source, kwargs):

scope = sentry_sdk.get_current_scope()
if scope.span:
_graphql_span = scope.span.start_child(op=op, description=operation_name)
_graphql_span = scope.span.start_child(op=op, name=operation_name)
else:
_graphql_span = sentry_sdk.start_span(op=op, description=operation_name)
_graphql_span = sentry_sdk.start_span(op=op, name=operation_name)

_graphql_span.set_data("graphql.document", source)
_graphql_span.set_data("graphql.operation.name", operation_name)
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/grpc/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def intercept_unary_unary(

with sentry_sdk.start_span(
op=OP.GRPC_CLIENT,
description="unary unary call to %s" % method.decode(),
name="unary unary call to %s" % method.decode(),
origin=SPAN_ORIGIN,
) as span:
span.set_data("type", "unary unary")
Expand Down Expand Up @@ -80,7 +80,7 @@ async def intercept_unary_stream(

with sentry_sdk.start_span(
op=OP.GRPC_CLIENT,
description="unary stream call to %s" % method.decode(),
name="unary stream call to %s" % method.decode(),
origin=SPAN_ORIGIN,
) as span:
span.set_data("type", "unary stream")
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def intercept_unary_unary(self, continuation, client_call_details, request):

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

with sentry_sdk.start_span(
op=OP.GRPC_CLIENT,
description="unary stream call to %s" % method,
name="unary stream call to %s" % method,
origin=SPAN_ORIGIN,
) as span:
span.set_data("type", "unary stream")
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def send(self, request, **kwargs):

with sentry_sdk.start_span(
op=OP.HTTP_CLIENT,
description="%s %s"
name="%s %s"
% (
request.method,
parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE,
Expand Down Expand Up @@ -109,7 +109,7 @@ async def send(self, request, **kwargs):

with sentry_sdk.start_span(
op=OP.HTTP_CLIENT,
description="%s %s"
name="%s %s"
% (
request.method,
parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE,
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/huey.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _sentry_enqueue(self, task):
# type: (Huey, Task) -> Optional[Union[Result, ResultGroup]]
with sentry_sdk.start_span(
op=OP.QUEUE_SUBMIT_HUEY,
description=task.name,
name=task.name,
origin=HueyIntegration.origin,
):
if not isinstance(task, PeriodicTask):
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/huggingface_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def new_text_generation(*args, **kwargs):

span = sentry_sdk.start_span(
op=consts.OP.HUGGINGFACE_HUB_CHAT_COMPLETIONS_CREATE,
description="Text Generation",
name="Text Generation",
origin=HuggingfaceHubIntegration.origin,
)
span.__enter__()
Expand Down
16 changes: 7 additions & 9 deletions sentry_sdk/integrations/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def _create_span(self, run_id, parent_id, **kwargs):
watched_span = WatchedSpan(sentry_sdk.start_span(**kwargs))

if kwargs.get("op", "").startswith("ai.pipeline."):
if kwargs.get("description"):
set_ai_pipeline_name(kwargs.get("description"))
if kwargs.get("name"):
set_ai_pipeline_name(kwargs.get("name"))
watched_span.is_pipeline = True

watched_span.span.__enter__()
Expand Down Expand Up @@ -186,7 +186,7 @@ def on_llm_start(
run_id,
kwargs.get("parent_run_id"),
op=OP.LANGCHAIN_RUN,
description=kwargs.get("name") or "Langchain LLM call",
name=kwargs.get("name") or "Langchain LLM call",
origin=LangchainIntegration.origin,
)
span = watched_span.span
Expand All @@ -208,7 +208,7 @@ def on_chat_model_start(self, serialized, messages, *, run_id, **kwargs):
run_id,
kwargs.get("parent_run_id"),
op=OP.LANGCHAIN_CHAT_COMPLETIONS_CREATE,
description=kwargs.get("name") or "Langchain Chat Model",
name=kwargs.get("name") or "Langchain Chat Model",
origin=LangchainIntegration.origin,
)
span = watched_span.span
Expand Down Expand Up @@ -312,7 +312,7 @@ def on_chain_start(self, serialized, inputs, *, run_id, **kwargs):
if kwargs.get("parent_run_id") is not None
else OP.LANGCHAIN_PIPELINE
),
description=kwargs.get("name") or "Chain execution",
name=kwargs.get("name") or "Chain execution",
origin=LangchainIntegration.origin,
)
metadata = kwargs.get("metadata")
Expand Down Expand Up @@ -345,7 +345,7 @@ def on_agent_action(self, action, *, run_id, **kwargs):
run_id,
kwargs.get("parent_run_id"),
op=OP.LANGCHAIN_AGENT,
description=action.tool or "AI tool usage",
name=action.tool or "AI tool usage",
origin=LangchainIntegration.origin,
)
if action.tool_input and should_send_default_pii() and self.include_prompts:
Expand Down Expand Up @@ -378,9 +378,7 @@ def on_tool_start(self, serialized, input_str, *, run_id, **kwargs):
run_id,
kwargs.get("parent_run_id"),
op=OP.LANGCHAIN_TOOL,
description=serialized.get("name")
or kwargs.get("name")
or "AI tool usage",
name=serialized.get("name") or kwargs.get("name") or "AI tool usage",
origin=LangchainIntegration.origin,
)
if should_send_default_pii() and self.include_prompts:
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/litestar.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async def _create_span_call(self, scope, receive, send):
middleware_name = self.__class__.__name__
with sentry_sdk.start_span(
op=OP.MIDDLEWARE_LITESTAR,
description=middleware_name,
name=middleware_name,
origin=LitestarIntegration.origin,
) as middleware_span:
middleware_span.set_tag("litestar.middleware_name", middleware_name)
Expand All @@ -151,7 +151,7 @@ async def _sentry_receive(*args, **kwargs):
return await receive(*args, **kwargs)
with sentry_sdk.start_span(
op=OP.MIDDLEWARE_LITESTAR_RECEIVE,
description=getattr(receive, "__qualname__", str(receive)),
name=getattr(receive, "__qualname__", str(receive)),
origin=LitestarIntegration.origin,
) as span:
span.set_tag("litestar.middleware_name", middleware_name)
Expand All @@ -168,7 +168,7 @@ async def _sentry_send(message):
return await send(message)
with sentry_sdk.start_span(
op=OP.MIDDLEWARE_LITESTAR_SEND,
description=getattr(send, "__qualname__", str(send)),
name=getattr(send, "__qualname__", str(send)),
origin=LitestarIntegration.origin,
) as span:
span.set_tag("litestar.middleware_name", middleware_name)
Expand Down
Loading
Loading