diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-06 15:39:14 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-12 16:24:51 +0000 |
commit | 0b96bb793e7e5d3935804b8f0ccaf415006388a9 (patch) | |
tree | c28651d834294b79234828bde03ca4de813e8cde /synapse/metrics/__init__.py | |
parent | Bugfix to rendering output of vectored TimerMetrics (diff) | |
download | synapse-0b96bb793e7e5d3935804b8f0ccaf415006388a9.tar.xz |
Have all @metrics.counted use a single metric name vectored on the method name, rather than a brand new scalar counter per counted method
Diffstat (limited to 'synapse/metrics/__init__.py')
-rw-r--r-- | synapse/metrics/__init__.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py index c00f088fff..443d67f41c 100644 --- a/synapse/metrics/__init__.py +++ b/synapse/metrics/__init__.py @@ -63,10 +63,17 @@ class Metrics(object): def counted(self, func): """ A method decorator that registers a counter, to count invocations of this method. """ - counter = self.register_counter(func.__name__) + if not hasattr(self, "method_counter"): + self.method_counter = self.register_counter( + "calls", + labels=["method"] + ) + + counter = self.method_counter + name = func.__name__ def wrapped(*args, **kwargs): - counter.inc() + counter.inc(name) return func(*args, **kwargs) return wrapped |