Prometheus histograms are cumalative

This commit is contained in:
Erik Johnston 2019-06-14 14:07:32 +01:00
parent d0530382ee
commit 3ed595e327
3 changed files with 12 additions and 12 deletions

View file

@ -224,7 +224,6 @@ class BucketCollector(object):
for i, bound in enumerate(self.buckets): for i, bound in enumerate(self.buckets):
if x <= bound: if x <= bound:
buckets[bound] = buckets.get(bound, 0) + data[x] buckets[bound] = buckets.get(bound, 0) + data[x]
break
for i in self.buckets: for i in self.buckets:
res.append([str(i), buckets.get(i, 0)]) res.append([str(i), buckets.get(i, 0)])

View file

@ -228,7 +228,8 @@ class EventsStore(
self._state_resolution_handler = hs.get_state_resolution_handler() self._state_resolution_handler = hs.get_state_resolution_handler()
# Collect metrics on the number of forward extremities that exist. # Collect metrics on the number of forward extremities that exist.
self._current_forward_extremities_amount = {} # Counter of number of extremities to count
self._current_forward_extremities_amount = c_counter()
BucketCollector( BucketCollector(
"synapse_forward_extremities", "synapse_forward_extremities",

View file

@ -64,16 +64,16 @@ class ExtremStatisticsTestCase(HomeserverTestCase):
expected = set([ expected = set([
b'synapse_forward_extremities_bucket{le="1.0"} 0.0', b'synapse_forward_extremities_bucket{le="1.0"} 0.0',
b'synapse_forward_extremities_bucket{le="2.0"} 2.0', b'synapse_forward_extremities_bucket{le="2.0"} 2.0',
b'synapse_forward_extremities_bucket{le="3.0"} 0.0', b'synapse_forward_extremities_bucket{le="3.0"} 2.0',
b'synapse_forward_extremities_bucket{le="5.0"} 0.0', b'synapse_forward_extremities_bucket{le="5.0"} 2.0',
b'synapse_forward_extremities_bucket{le="7.0"} 1.0', b'synapse_forward_extremities_bucket{le="7.0"} 3.0',
b'synapse_forward_extremities_bucket{le="10.0"} 0.0', b'synapse_forward_extremities_bucket{le="10.0"} 3.0',
b'synapse_forward_extremities_bucket{le="15.0"} 0.0', b'synapse_forward_extremities_bucket{le="15.0"} 3.0',
b'synapse_forward_extremities_bucket{le="20.0"} 0.0', b'synapse_forward_extremities_bucket{le="20.0"} 3.0',
b'synapse_forward_extremities_bucket{le="50.0"} 0.0', b'synapse_forward_extremities_bucket{le="50.0"} 3.0',
b'synapse_forward_extremities_bucket{le="100.0"} 0.0', b'synapse_forward_extremities_bucket{le="100.0"} 3.0',
b'synapse_forward_extremities_bucket{le="200.0"} 0.0', b'synapse_forward_extremities_bucket{le="200.0"} 3.0',
b'synapse_forward_extremities_bucket{le="500.0"} 0.0', b'synapse_forward_extremities_bucket{le="500.0"} 3.0',
b'synapse_forward_extremities_bucket{le="+Inf"} 3.0', b'synapse_forward_extremities_bucket{le="+Inf"} 3.0',
b'synapse_forward_extremities_count 3.0', b'synapse_forward_extremities_count 3.0',
b'synapse_forward_extremities_sum 10.0', b'synapse_forward_extremities_sum 10.0',