Skip to content

Commit

Permalink
Squash #2041 - Patch from else where
Browse files Browse the repository at this point in the history
  • Loading branch information
MackHalliday committed Nov 19, 2024
1 parent 62d1fe9 commit 0d94795
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 0 additions & 3 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from flask_marshmallow import Marshmallow
from flask_migrate import Migrate
from time import monotonic
from ddtrace import patch
from notifications_utils.clients.zendesk.zendesk_client import ZendeskClient
from notifications_utils.clients.statsd.statsd_client import StatsdClient
from notifications_utils.clients.redis.redis_client import RedisClient
Expand Down Expand Up @@ -42,8 +41,6 @@

load_dotenv()

patch(celery=True)

migrate = Migrate()
ma = Marshmallow()
notify_celery = NotifyCelery()
Expand Down
7 changes: 6 additions & 1 deletion app/celery/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
from celery import Celery, Task
from celery.signals import worker_process_shutdown, worker_shutting_down, worker_process_init
from flask import current_app
from ddtrace import patch, tracer

patch(celery=True)
current_app.logger.info('Celery has been patched with DataDog APM.')


@worker_process_init.connect
Expand Down Expand Up @@ -73,7 +77,8 @@ def __call__(
# ensure task has flask context to access config, logger, etc
with app.app_context():
self.start = time.time()
return super().__call__(*args, **kwargs)
with tracer.trace(self.name, service='celery-task'):
return super().__call__(*args, **kwargs)

return NotifyTask

Expand Down

0 comments on commit 0d94795

Please sign in to comment.