use of io.opencensus.stats.BucketBoundaries in project instrumentation-java by census-instrumentation.
the class MutableAggregationTest method testCreateEmpty.
@Test
public void testCreateEmpty() {
assertThat(MutableSumDouble.create().getSum()).isWithin(TOLERANCE).of(0);
assertThat(MutableSumLong.create().getSum()).isWithin(TOLERANCE).of(0);
assertThat(MutableCount.create().getCount()).isEqualTo(0);
assertThat(MutableMean.create().getMean()).isWithin(TOLERANCE).of(0);
assertThat(MutableLastValueDouble.create().getLastValue()).isNaN();
assertThat(MutableLastValueLong.create().getLastValue()).isNaN();
BucketBoundaries bucketBoundaries = BucketBoundaries.create(Arrays.asList(0.1, 2.2, 33.3));
MutableDistribution mutableDistribution = MutableDistribution.create(bucketBoundaries);
assertThat(mutableDistribution.getMean()).isWithin(TOLERANCE).of(0);
assertThat(mutableDistribution.getCount()).isEqualTo(0);
assertThat(mutableDistribution.getSumOfSquaredDeviations()).isWithin(TOLERANCE).of(0);
assertThat(mutableDistribution.getBucketCounts()).isEqualTo(new long[4]);
assertThat(mutableDistribution.getExemplars()).isEqualTo(new Exemplar[4]);
MutableDistribution mutableDistributionNoHistogram = MutableDistribution.create(BUCKET_BOUNDARIES_EMPTY);
assertThat(mutableDistributionNoHistogram.getExemplars()).isNull();
}
use of io.opencensus.stats.BucketBoundaries in project instrumentation-java by census-instrumentation.
the class RecordUtilsTest method createMutableAggregation.
@Test
public void createMutableAggregation() {
BucketBoundaries bucketBoundaries = BucketBoundaries.create(Arrays.asList(-1.0, 0.0, 1.0));
assertThat(RecordUtils.createMutableAggregation(Sum.create(), MEASURE_DOUBLE).toAggregationData()).isEqualTo(SumDataDouble.create(0));
assertThat(RecordUtils.createMutableAggregation(Sum.create(), MEASURE_LONG).toAggregationData()).isEqualTo(SumDataLong.create(0));
assertThat(RecordUtils.createMutableAggregation(Count.create(), MEASURE_DOUBLE).toAggregationData()).isEqualTo(CountData.create(0));
assertThat(RecordUtils.createMutableAggregation(Count.create(), MEASURE_LONG).toAggregationData()).isEqualTo(CountData.create(0));
assertThat(RecordUtils.createMutableAggregation(Mean.create(), MEASURE_DOUBLE).toAggregationData()).isEqualTo(MeanData.create(0, 0));
assertThat(RecordUtils.createMutableAggregation(Mean.create(), MEASURE_LONG).toAggregationData()).isEqualTo(MeanData.create(0, 0));
assertThat(RecordUtils.createMutableAggregation(LastValue.create(), MEASURE_DOUBLE).toAggregationData()).isEqualTo(LastValueDataDouble.create(Double.NaN));
assertThat(RecordUtils.createMutableAggregation(LastValue.create(), MEASURE_LONG).toAggregationData()).isEqualTo(LastValueDataLong.create(0));
MutableDistribution mutableDistribution = (MutableDistribution) RecordUtils.createMutableAggregation(Distribution.create(bucketBoundaries), MEASURE_DOUBLE);
assertThat(mutableDistribution.getSumOfSquaredDeviations()).isWithin(EPSILON).of(0);
assertThat(mutableDistribution.getBucketCounts()).isEqualTo(new long[2]);
}
Aggregations