diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-06 18:40:20 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-12 16:24:51 +0000 |
commit | 0e847540c3aa1c471a00b3200f7f18e48004b48d (patch) | |
tree | d60815c3e4a05b7a0cfebab4b692b44ff9dbb765 /synapse/metrics | |
parent | Kill unused CounterMetric.fetch() method (diff) | |
download | synapse-0e847540c3aa1c471a00b3200f7f18e48004b48d.tar.xz |
Prometheus needs "escaped" label values
Diffstat (limited to 'synapse/metrics')
-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 93508eeacc..922cb5a6f1 100644 --- a/synapse/metrics/metric.py +++ b/synapse/metrics/metric.py @@ -35,12 +35,16 @@ class BaseMetric(object): def is_scalar(self): return not len(self.labels) + def _render_labelvalue(self, value): + # TODO: some kind of value escape + return '"%s"' % (value) + def _render_key(self, values): if self.is_scalar(): return "" - # TODO: some kind of value escape return "{%s}" % ( - ",".join(["%s=%s" % kv for kv in zip(self.labels, values)]) + ",".join(["%s=%s" % (k, self._render_labelvalue(v)) + for k, v in zip(self.labels, values)]) ) def render(self): |