From 4d5157cdb5f019b9cce6f5b27733eced9155411a Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sun, 3 Nov 2019 01:58:53 -0700 Subject: [PATCH] Fix a mistake with allowing reuse of name in @timed() --- common/common/stats.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/common/stats.py b/common/common/stats.py index 5b1ddc4..d8f83bf 100644 --- a/common/common/stats.py +++ b/common/common/stats.py @@ -91,8 +91,8 @@ def timed(name=None, # can't safely assign to name inside closure, we use a new _name variable instead _name = fn.__name__ if name is None else name - if name in metrics: - latency, cputime = metrics[name] + if _name in metrics: + latency, cputime = metrics[_name] else: latency = prom.Histogram( "{}_latency".format(_name), @@ -106,9 +106,9 @@ def timed(name=None, labels.keys() + ['error', 'type'], buckets=buckets, ) - metrics[name] = latency, cputime + metrics[_name] = latency, cputime if normalize: - normname = '{} normalized'.format(name) + normname = '{} normalized'.format(_name) if normname in metrics: normal_latency, normal_cputime = metrics[normname] else: