It looks like there were a few bugs added in #149 and #287:
Exemplars are always attached to the last bucket:
from opencensus.stats.aggregation import DistributionAggregation
da = DistributionAggregation(list(map(float, range(0, 11))))
ad = da.aggregation_data
for dp in range(10):
ad.add_sample(dp, dt.now(), {"trace_id": "dead", "span_id": "beef"})
ad.exemplars
{11: <opencensus.stats.aggregation_data.Exemplar at 0x10ccf6390>}
Off-by-one error adding a value greater than the last bucket boundary:
from datetime import datetime as dt
da = DistributionAggregation([1, 3, 5])
ad = da.aggregation_data
ad.add_sample(float('-inf'), dt.now(), {"trace_id": "dead", "span_id": "beef"})
ad.add_sample(2, dt.now(), {"trace_id": "dead", "span_id": "beef"})
ad.add_sample(4, dt.now(), {"trace_id": "dead", "span_id": "beef"})
ad.add_sample(float('inf'), dt.now(), {"trace_id": "dead", "span_id": "beef"})
ad.counts_per_bucket
Min/max are 0 by default, which doesn't work for e.g. histograms without 0-valued points:
da = DistributionAggregation(list(map(float, range(0, 11))))
ad = da.aggregation_data
for dp in range(10, 20):
ad.add_sample(dp, dt.now(), {"trace_id": "dead", "span_id": "beef"})
ad.min # should be 10
...or histograms with all negative points:
da = DistributionAggregation(list(map(float, range(0, 11))))
ad = da.aggregation_data
for dp in range(-20, -10):
ad.add_sample(dp, dt.now(), {"trace_id": "dead", "span_id": "beef"})
ad.max # should be -10
It looks like there were a few bugs added in #149 and #287:
Exemplars are always attached to the last bucket:
{11: <opencensus.stats.aggregation_data.Exemplar at 0x10ccf6390>}Off-by-one error adding a value greater than the last bucket boundary:
Min/max are 0 by default, which doesn't work for e.g. histograms without 0-valued points:
0...or histograms with all negative points:
0