Skip to content

Commit 167cef7

Browse files
Add conditional check for delivery_info's existence (#3083)
Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
1 parent 69a3b29 commit 167cef7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sentry_sdk/integrations/celery/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,12 @@ def _set_messaging_destination_name(task, span):
333333
"""Set "messaging.destination.name" tag for span"""
334334
with capture_internal_exceptions():
335335
delivery_info = task.request.delivery_info
336-
routing_key = delivery_info.get("routing_key")
337-
if delivery_info.get("exchange") == "" and routing_key is not None:
338-
# Empty exchange indicates the default exchange, meaning the tasks
339-
# are sent to the queue with the same name as the routing key.
340-
span.set_data(SPANDATA.MESSAGING_DESTINATION_NAME, routing_key)
336+
if delivery_info:
337+
routing_key = delivery_info.get("routing_key")
338+
if delivery_info.get("exchange") == "" and routing_key is not None:
339+
# Empty exchange indicates the default exchange, meaning the tasks
340+
# are sent to the queue with the same name as the routing key.
341+
span.set_data(SPANDATA.MESSAGING_DESTINATION_NAME, routing_key)
341342

342343

343344
def _wrap_task_call(task, f):

0 commit comments

Comments
 (0)