From 328396015293aba8d64de3484685d765f5886d1c Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Fri, 17 May 2024 12:05:54 +0200 Subject: [PATCH] ref(celery): Add comment about kwargs_headers This comment clarifies a potentially confusing part of the code. --- sentry_sdk/integrations/celery/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index 3e0c58ae44..049708743a 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -447,7 +447,11 @@ def sentry_publish(self, *args, **kwargs): # type: (Producer, *Any, **Any) -> Any kwargs_headers = kwargs.get("headers", {}) if not isinstance(kwargs_headers, Mapping): - # Ensure kwargs_headers is a Mapping, so we can safely call get() + # Ensure kwargs_headers is a Mapping, so we can safely call get(). + # We don't expect this to happen, but it's better to be safe. Even + # if it does happen, only our instrumentation breaks. This line + # does not overwrite kwargs["headers"], so the original publish + # method will still work. kwargs_headers = {} task_name = kwargs_headers.get("task")