use of io.opencensus.implcore.stats.MutableAggregation.MutableMean in project instrumentation-java by census-instrumentation.
the class IntervalBucketTest method testRecord.
@Test
public void testRecord() {
IntervalBucket bucket = new IntervalBucket(START, MINUTE, MEAN, MEASURE_DOUBLE);
List<TagValue> tagValues1 = Arrays.<TagValue>asList(TagValue.create("VALUE1"));
List<TagValue> tagValues2 = Arrays.<TagValue>asList(TagValue.create("VALUE2"));
bucket.record(tagValues1, 5.0, Collections.<String, AttachmentValue>emptyMap(), START);
bucket.record(tagValues1, 15.0, Collections.<String, AttachmentValue>emptyMap(), START);
bucket.record(tagValues2, 10.0, Collections.<String, AttachmentValue>emptyMap(), START);
assertThat(bucket.getTagValueAggregationMap().keySet()).containsExactly(tagValues1, tagValues2);
MutableMean mutableMean1 = (MutableMean) bucket.getTagValueAggregationMap().get(tagValues1);
MutableMean mutableMean2 = (MutableMean) bucket.getTagValueAggregationMap().get(tagValues2);
assertThat(mutableMean1.getSum()).isWithin(TOLERANCE).of(20);
assertThat(mutableMean2.getSum()).isWithin(TOLERANCE).of(10);
assertThat(mutableMean1.getCount()).isEqualTo(2);
assertThat(mutableMean2.getCount()).isEqualTo(1);
}
Aggregations