From fa72f4b282188e4566a74e89f57cd09398667ca5 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 9 Apr 2024 14:59:32 +0200 Subject: [PATCH 1/2] Add comments for args and kwargs --- sentry_sdk/integrations/celery/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index b3cbfe8acb..760e724fa7 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -168,6 +168,14 @@ def apply_async(*args, **kwargs): # type: (*Any, **Any) -> Any task = args[0] + from pprint import pprint + + print("######### args (producer) #############") + pprint(args) + print("######### kwargs (producer) #############") + pprint(kwargs) + # TODO: this is the producer side. here we can add data from args/kwargs to the span. + # Do not create a span when the task is a Celery Beat task # (Because we do not have a transaction in that case) span_mgr = ( @@ -272,6 +280,15 @@ def _wrap_tracer(task, f): def _inner(*args, **kwargs): # type: (*Any, **Any) -> Any with isolation_scope() as scope: + from pprint import pprint + + print("######### args (consumer) #############") + pprint(args) + print("######### kwargs (consumer) #############") + pprint(kwargs) + # TODO: this is where the consumer picks up the task and processes it. + # in the args you find a lot of information about the task that can be added to the transaction + scope._name = "celery" scope.clear_breadcrumbs() scope.add_event_processor(_make_event_processor(task, *args, **kwargs)) From 5ae8dc776f3d3b06a93b748704397dfd1dbb46f6 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Thu, 11 Apr 2024 16:07:34 +0200 Subject: [PATCH 2/2] more debugging printings --- sentry_sdk/integrations/celery/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index 760e724fa7..88a9b64618 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -280,12 +280,14 @@ def _wrap_tracer(task, f): def _inner(*args, **kwargs): # type: (*Any, **Any) -> Any with isolation_scope() as scope: - from pprint import pprint print("######### args (consumer) #############") - pprint(args) + print(args) print("######### kwargs (consumer) #############") - pprint(kwargs) + print(kwargs) + + print("######### task #############") + print(task.request.retries) # TODO: this is where the consumer picks up the task and processes it. # in the args you find a lot of information about the task that can be added to the transaction @@ -340,6 +342,11 @@ def _wrap_task_call(task, f): @wraps(f) def _inner(*args, **kwargs): # type: (*Any, **Any) -> Any + + print("######### args (task call) #############") + print(task.request.retries) + print("######### kwargs (task call) #############") + print(kwargs) try: return f(*args, **kwargs) except Exception: