Search in sources :

Example 1 with AtlasMeterRegistry

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));
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) AtlasMeterRegistry(io.micrometer.atlas.AtlasMeterRegistry) Measurement(io.micrometer.core.instrument.Measurement) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Gauge(io.micrometer.core.instrument.Gauge) Test(org.junit.Test)

Aggregations

AtlasMeterRegistry (io.micrometer.atlas.AtlasMeterRegistry)1 Gauge (io.micrometer.core.instrument.Gauge)1 Measurement (io.micrometer.core.instrument.Measurement)1 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)1 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 Test (org.junit.Test)1