diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-04 17:58:10 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-12 16:24:50 +0000 |
commit | 23ab0c68c28e60e0f8774ee4099b2abe876374d0 (patch) | |
tree | fe26017e4b235653aaa99cfb48e348094c8c0838 /synapse | |
parent | Neater introspection methods on BaseMetric so that subclasses don't need to t... (diff) | |
download | synapse-23ab0c68c28e60e0f8774ee4099b2abe876374d0.tar.xz |
Implement vector CallbackMetrics
Diffstat (limited to '')
-rw-r--r-- | synapse/metrics/metric.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/metrics/metric.py b/synapse/metrics/metric.py index e8c15a60e8..4df5ebfda6 100644 --- a/synapse/metrics/metric.py +++ b/synapse/metrics/metric.py @@ -79,9 +79,13 @@ class CallbackMetric(BaseMetric): self.callback = callback def render(self): - # TODO(paul): work out something we can do with keys and vectors - return ["%s %d" % (self.name, self.callback())] + value = self.callback() + if self.is_scalar(): + return ["%s %d" % (self.name, value)] + + return ["%s{%s} %d" % (self.name, self._render_key(k), value[k]) + for k in sorted(value.keys())] class CacheMetric(object): """A combination of two CounterMetrics, one to count cache hits and one to |