use of io.micrometer.core.instrument.MockClock in project micrometer by micrometer-metrics.
the class TimeWindowPercentileHistogramTest method percentilesWithNoSamples.
@Test
void percentilesWithNoSamples() {
DistributionStatisticConfig config = DistributionStatisticConfig.builder().percentiles(0.5).build().merge(DistributionStatisticConfig.DEFAULT);
TimeWindowPercentileHistogram histogram = new TimeWindowPercentileHistogram(new MockClock(), config, false);
assertThat(histogram.takeSnapshot(0, 0, 0).percentileValues()).containsExactly(new ValueAtPercentile(0.5, 0));
}
use of io.micrometer.core.instrument.MockClock in project micrometer by micrometer-metrics.
the class TimeWindowPercentileHistogramTest method percentiles.
@Test
void percentiles() {
TimeWindowPercentileHistogram histogram = new TimeWindowPercentileHistogram(new MockClock(), DistributionStatisticConfig.builder().percentiles(0.5, 0.9, 0.95).minimumExpectedValue((long) millisToUnit(1, TimeUnit.NANOSECONDS)).maximumExpectedValue((long) secondsToUnit(30, TimeUnit.NANOSECONDS)).build().merge(DistributionStatisticConfig.DEFAULT), false);
for (long i = 1; i <= 10; i++) {
histogram.recordLong((long) millisToUnit(i, TimeUnit.NANOSECONDS));
}
assertThat(histogram.takeSnapshot(0, 0, 0).percentileValues()).anyMatch(p -> percentileValueIsApproximately(p, 0.5, 5e6)).anyMatch(p -> percentileValueIsApproximately(p, 0.9, 9e6)).anyMatch(p -> percentileValueIsApproximately(p, 0.95, 10e6));
}
use of io.micrometer.core.instrument.MockClock in project micrometer by micrometer-metrics.
the class InfluxMeterRegistryFieldToStringTest method testWithEnglishLocale.
@Test
void testWithEnglishLocale() {
Locale.setDefault(Locale.ENGLISH);
InfluxMeterRegistry instance = new InfluxMeterRegistry(k -> null, new MockClock());
InfluxMeterRegistry.Field field = instance.new Field("value", 0.01);
assertThat(field.toString()).isEqualTo("value=0.01");
}
use of io.micrometer.core.instrument.MockClock in project micrometer by micrometer-metrics.
the class InfluxMeterRegistryFieldToStringTest method testWithSwedishLocale.
@Test
void testWithSwedishLocale() {
Locale.setDefault(new Locale("sv", "SE"));
InfluxMeterRegistry instance = new InfluxMeterRegistry(k -> null, new MockClock());
InfluxMeterRegistry.Field field = instance.new Field("value", 0.01);
assertThat(field.toString()).isEqualTo("value=0.01");
}
Aggregations