##// END OF EJS Templates
metrics: fixed celery task names, fixed hiistogram type metrics, client small fixes
super-admin -
r4807:1bd9683a default
parent child Browse files
Show More
@@ -15,12 +15,11 b' TAG_INVALID_CHARS_RE = re.compile('
15 15 TAG_INVALID_CHARS_SUBS = "_"
16 16
17 17 # we save and expose methods called by statsd for discovery
18 stat_dict = {
18 buckets_dict = {
19 19
20 20 }
21 21
22 22
23
24 23 @lru_cache(maxsize=500)
25 24 def _normalize_tags_with_cache(tag_list):
26 25 return [TAG_INVALID_CHARS_RE.sub(TAG_INVALID_CHARS_SUBS, tag) for tag in tag_list]
@@ -96,8 +95,8 b' class StatsClientBase(object):'
96 95 self._after(self._prepare(stat, value, rate, tags))
97 96
98 97 def _prepare(self, stat, value, rate, tags=None):
99 global stat_dict
100 stat_dict[stat] = 1
98 global buckets_dict
99 buckets_dict[stat] = 1
101 100
102 101 if rate < 1:
103 102 if random.random() > rate:
@@ -47,17 +47,14 b' def run_task(task, *args, **kwargs):'
47 47 if task is None:
48 48 raise ValueError('Got non-existing task for execution')
49 49
50 statsd = StatsdClient.statsd
51 50 exec_mode = 'sync'
52 51
53 52 if rhodecode.CELERY_ENABLED:
54
53 t = None
55 54 try:
56 55 t = task.apply_async(args=args, kwargs=kwargs)
57 56 log.debug('executing task %s:%s in async mode', t.task_id, task)
58 57 exec_mode = 'async'
59 return t
60
61 58 except socket.error as e:
62 59 if isinstance(e, IOError) and e.errno == 111:
63 60 log.error('Unable to connect to celeryd `%s`. Sync execution', e)
@@ -73,9 +70,15 b' def run_task(task, *args, **kwargs):'
73 70 else:
74 71 log.debug('executing task %s:%s in sync mode', 'TASK', task)
75 72
73 statsd = StatsdClient.statsd
76 74 if statsd:
75 task_repr = getattr(task, 'name', task)
77 76 statsd.incr('rhodecode_celery_task_total', tags=[
78 'task:{}'.format(task),
77 'task:{}'.format(task_repr),
79 78 'mode:{}'.format(exec_mode)
80 79 ])
80
81 # we got async task, return it after statsd call
82 if t:
83 return t
81 84 return ResultWrapper(task(*args, **kwargs))
@@ -53,7 +53,7 b' class RequestWrapperTween(object):'
53 53 _ver_ = rhodecode.__version__
54 54 _path = safe_str(get_access_path(request.environ))
55 55 _auth_user = self._get_user_info(request)
56 user_id = getattr(_auth_user, 'user_id', _auth_user)
56
57 57 total = time.time() - start
58 58 log.info(
59 59 'Req[%4s] %s %s Request to %s time: %.4fs [%s], RhodeCode %s',
@@ -67,10 +67,9 b' class RequestWrapperTween(object):'
67 67 resp_code = response.status_code
68 68 elapsed_time_ms = round(1000.0 * total) # use ms only
69 69 statsd.timing(
70 'rhodecode_req_timing', elapsed_time_ms,
70 "rhodecode_req_timing.histogram", elapsed_time_ms,
71 71 tags=[
72 72 "view_name:{}".format(match_route),
73 #"user:{}".format(user_id),
74 73 "code:{}".format(resp_code)
75 74 ],
76 75 use_decimals=False
@@ -78,7 +77,6 b' class RequestWrapperTween(object):'
78 77 statsd.incr(
79 78 'rhodecode_req_total', tags=[
80 79 "view_name:{}".format(match_route),
81 #"user:{}".format(user_id),
82 80 "code:{}".format(resp_code)
83 81 ])
84 82
General Comments 0
You need to be logged in to leave comments. Login now