1+ import logging
2+
13from ddtrace import Pin
24
35from celery import registry
1214)
1315
1416
17+ log = logging .getLogger (__name__ )
18+
19+
1520def trace_prerun (* args , ** kwargs ):
1621 # safe-guard to avoid crashes in case the signals API
1722 # changes in Celery
1823 task = kwargs .get ('sender' )
1924 task_id = kwargs .get ('task_id' )
2025 if task is None or task_id is None :
26+ log .debug ('unable to extract the Task and the task_id. This version of Celery may not be supported.' )
2127 return
2228
2329 # retrieve the task Pin or fallback to the global one
@@ -36,6 +42,7 @@ def trace_postrun(*args, **kwargs):
3642 task = kwargs .get ('sender' )
3743 task_id = kwargs .get ('task_id' )
3844 if task is None or task_id is None :
45+ log .debug ('unable to extract the Task and the task_id. This version of Celery may not be supported.' )
3946 return
4047
4148 # retrieve and finish the Span
@@ -62,6 +69,7 @@ def trace_before_publish(*args, **kwargs):
6269 # safe-guard to avoid crashes in case the signals API
6370 # changes in Celery
6471 if task is None or task_id is None :
72+ log .debug ('unable to extract the Task and the task_id. This version of Celery may not be supported.' )
6573 return
6674
6775 # propagate the `Span` in the current task Context
@@ -88,6 +96,7 @@ def trace_after_publish(*args, **kwargs):
8896 # safe-guard to avoid crashes in case the signals API
8997 # changes in Celery
9098 if task is None or task_id is None :
99+ log .debug ('unable to extract the Task and the task_id. This version of Celery may not be supported.' )
91100 return
92101
93102 # retrieve and finish the Span
@@ -105,6 +114,7 @@ def trace_failure(*args, **kwargs):
105114 task = kwargs .get ('sender' )
106115 task_id = kwargs .get ('task_id' )
107116 if task is None or task_id is None :
117+ log .debug ('unable to extract the Task and the task_id. This version of Celery may not be supported.' )
108118 return
109119
110120 # retrieve and finish the Span
0 commit comments