##// END OF EJS Templates
statsd: better task execution reporting on celery
super-admin -
r4892:22facf19 default
parent child Browse files
Show More
@@ -64,13 +64,6 b' def run_task(task, *args, **kwargs):'
64 t = None
64 t = None
65 if rhodecode.CELERY_ENABLED and allow_async:
65 if rhodecode.CELERY_ENABLED and allow_async:
66
66
67 statsd = StatsdClient.statsd
68 if statsd:
69 task_repr = getattr(task, 'name', task)
70 statsd.incr('rhodecode_celery_task_total', tags=[
71 'task:{}'.format(task_repr)
72 ])
73
74 try:
67 try:
75 t = task.apply_async(args=args, kwargs=kwargs)
68 t = task.apply_async(args=args, kwargs=kwargs)
76 log.debug('executing task %s:%s in async mode', t.task_id, task)
69 log.debug('executing task %s:%s in async mode', t.task_id, task)
@@ -88,6 +81,13 b' def run_task(task, *args, **kwargs):'
88
81
89 else:
82 else:
90 log.debug('executing task %s:%s in sync mode', 'TASK', task)
83 log.debug('executing task %s:%s in sync mode', 'TASK', task)
84 statsd = StatsdClient.statsd
85 if statsd:
86 task_repr = getattr(task, 'name', task)
87 statsd.incr('rhodecode_celery_task_total', tags=[
88 'task:{}'.format(task_repr),
89 'mode:sync'
90 ])
91
91
92 # we got async task, return it after statsd call
92 # we got async task, return it after statsd call
93 if t:
93 if t:
@@ -41,6 +41,7 b' from kombu.serialization import register'
41
41
42 import rhodecode
42 import rhodecode
43
43
44 from rhodecode.lib.statsd_client import StatsdClient
44 from rhodecode.lib.celerylib.utils import parse_ini_vars, ping_db
45 from rhodecode.lib.celerylib.utils import parse_ini_vars, ping_db
45 from rhodecode.lib.ext_json import json
46 from rhodecode.lib.ext_json import json
46 from rhodecode.lib.pyramid_utils import bootstrap, setup_logging
47 from rhodecode.lib.pyramid_utils import bootstrap, setup_logging
@@ -182,6 +183,13 b' def on_beat_init(sender=None, conf=None,'
182 @signals.task_prerun.connect
183 @signals.task_prerun.connect
183 def task_prerun_signal(task_id, task, args, **kwargs):
184 def task_prerun_signal(task_id, task, args, **kwargs):
184 ping_db()
185 ping_db()
186 statsd = StatsdClient.statsd
187 if statsd:
188 task_repr = getattr(task, 'name', task)
189 statsd.incr('rhodecode_celery_task_total', tags=[
190 'task:{}'.format(task_repr),
191 'mode:async'
192 ])
185
193
186
194
187 @signals.task_success.connect
195 @signals.task_success.connect
@@ -192,6 +200,7 b' def task_success_signal(result, **kwargs'
192 closer()
200 closer()
193
201
194
202
203
195 @signals.task_retry.connect
204 @signals.task_retry.connect
196 def task_retry_signal(
205 def task_retry_signal(
197 request, reason, einfo, **kwargs):
206 request, reason, einfo, **kwargs):
General Comments 0
You need to be logged in to leave comments. Login now