File tree Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 1- # Third party
21import celery
32
4- # Project
3+ from wrapt import wrap_function_wrapper as _w
4+
55from .app import patch_app , unpatch_app
6+ from .registry import _wrap_register
7+ from ...utils .wrappers import unwrap as _u
68
79
810def patch ():
9- """ patch will add all available tracing to the celery library """
11+ """Instrument Celery base application and the `TaskRegistry` so
12+ that any new registered task is automatically instrumented
13+ """
1014 setattr (celery , 'Celery' , patch_app (celery .Celery ))
15+ _w ('celery.app.registry' , 'TaskRegistry.register' , _wrap_register )
1116
1217
1318def unpatch ():
14- """ unpatch will remove tracing from the celery library """
19+ """Removes instrumentation from Celery """
1520 setattr (celery , 'Celery' , unpatch_app (celery .Celery ))
21+ _u (celery .app .registry .TaskRegistry , 'register' )
Original file line number Diff line number Diff line change 1+ from .task import patch_task
2+
3+
4+ def _wrap_register (func , instance , args , kwargs ):
5+ """Wraps the `TaskRegistry.register` function so that everytime
6+ a `Task` is registered it is properly instrumented. This wrapper
7+ is required because in old-style tasks (Celery 1.0+) we cannot
8+ instrument the base class, otherwise a `Strategy` `KeyError`
9+ exception is raised.
10+ """
11+ # the original signature requires one positional argument so the
12+ # first and only parameter is the `Task` that must be instrumented
13+ task = args [0 ]
14+ patch_task (task )
15+ func (* args , ** kwargs )
Original file line number Diff line number Diff line change @@ -128,8 +128,7 @@ deps =
128128 celery31: celery>=3.1,<3.2
129129 celery40: celery>=4.0,<4.1
130130 celery41: celery>=4.1,<4.2
131- # TODO[manu] update to a stable version of Celery
132- celery42: celery ==4.2.0rc3
131+ celery42: celery>=4.2,<4.3
133132 ddtracerun: redis
134133 ddtracerun: celery
135134 elasticsearch16: elasticsearch>=1.6,<1.7
You can’t perform that action at this time.
0 commit comments