Skip to content

Commit

Permalink
Add conditional check for delivery_info's existence (#3083)
Browse files Browse the repository at this point in the history
Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
  • Loading branch information
cmanallen and antonpirker authored May 21, 2024
1 parent 69a3b29 commit 167cef7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sentry_sdk/integrations/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,12 @@ def _set_messaging_destination_name(task, span):
"""Set "messaging.destination.name" tag for span"""
with capture_internal_exceptions():
delivery_info = task.request.delivery_info
routing_key = delivery_info.get("routing_key")
if delivery_info.get("exchange") == "" and routing_key is not None:
# Empty exchange indicates the default exchange, meaning the tasks
# are sent to the queue with the same name as the routing key.
span.set_data(SPANDATA.MESSAGING_DESTINATION_NAME, routing_key)
if delivery_info:
routing_key = delivery_info.get("routing_key")
if delivery_info.get("exchange") == "" and routing_key is not None:
# Empty exchange indicates the default exchange, meaning the tasks
# are sent to the queue with the same name as the routing key.
span.set_data(SPANDATA.MESSAGING_DESTINATION_NAME, routing_key)


def _wrap_task_call(task, f):
Expand Down

0 comments on commit 167cef7

Please sign in to comment.