Skip to content

Commit bcae71d

Browse files
author
Emanuele Palazzetti
committed
[celery] update util.py to utils.py; removing duplicated / unused code
1 parent e067121 commit bcae71d

File tree

2 files changed

+1
-25
lines changed

2 files changed

+1
-25
lines changed

ddtrace/contrib/celery/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ddtrace.pin import _DD_PIN_NAME
55
from ddtrace.ext import AppTypes
66

7-
from .util import APP, WORKER_SERVICE
7+
from .constants import APP, WORKER_SERVICE
88
from .signals import (
99
trace_prerun,
1010
trace_postrun,

ddtrace/contrib/celery/util.py renamed to ddtrace/contrib/celery/utils.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
# stdlib
2-
import os
3-
41
from weakref import WeakValueDictionary
52

6-
# Project
7-
from ddtrace import Pin
8-
93
from .constants import CTX_KEY
104

11-
# Service info
12-
APP = 'celery'
13-
PRODUCER_SERVICE = os.environ.get('DATADOG_SERVICE_NAME') or 'celery-producer'
14-
WORKER_SERVICE = os.environ.get('DATADOG_SERVICE_NAME') or 'celery-worker'
15-
165

176
def tags_from_context(context):
187
"""Helper to extract meta values from a Celery Context"""
@@ -100,16 +89,3 @@ def retrieve_task_id(context):
10089
else:
10190
# Protocol Version 1
10291
return body.get('id')
103-
104-
105-
def require_pin(decorated):
106-
""" decorator for extracting the `Pin` from a wrapped method """
107-
def wrapper(wrapped, instance, args, kwargs):
108-
pin = Pin.get_from(instance)
109-
# Execute the original method if pin is not enabled
110-
if not pin or not pin.enabled():
111-
return wrapped(*args, **kwargs)
112-
113-
# Execute our decorated function
114-
return decorated(pin, wrapped, instance, args, kwargs)
115-
return wrapper

0 commit comments

Comments
 (0)