use of io.micrometer.atlas.AtlasMeterRegistry in project tutorials by eugenp.
the class MicrometerAtlasTest method givenCompositeRegistries_whenRecordMeter_thenAllRegistriesRecorded.
@Test
public void givenCompositeRegistries_whenRecordMeter_thenAllRegistriesRecorded() {
CompositeMeterRegistry compositeRegistry = new CompositeMeterRegistry();
SimpleMeterRegistry oneSimpleMeter = new SimpleMeterRegistry();
AtlasMeterRegistry atlasMeterRegistry = new AtlasMeterRegistry(atlasConfig, Clock.SYSTEM);
compositeRegistry.add(oneSimpleMeter);
compositeRegistry.add(atlasMeterRegistry);
compositeRegistry.gauge("baeldung.heat", 90);
Optional<Gauge> oneGauge = oneSimpleMeter.find("baeldung.heat").gauge();
assertTrue(oneGauge.isPresent());
Iterator<Measurement> measurements = oneGauge.get().measure().iterator();
assertTrue(measurements.hasNext());
assertThat(measurements.next().getValue(), equalTo(90.00));
Optional<Gauge> atlasGauge = atlasMeterRegistry.find("baeldung.heat").gauge();
assertTrue(atlasGauge.isPresent());
Iterator<Measurement> anotherMeasurements = atlasGauge.get().measure().iterator();
assertTrue(anotherMeasurements.hasNext());
assertThat(anotherMeasurements.next().getValue(), equalTo(90.00));
}
Aggregations