Search in sources :

Example 16 with Gauge

use of io.micrometer.core.instrument.Gauge in project micrometer by micrometer-metrics.

the class KairosMeterRegistryTest method writeGaugeShouldDropNanValue.

@Test
void writeGaugeShouldDropNanValue() {
    meterRegistry.gauge("my.gauge", Double.NaN);
    Gauge gauge = meterRegistry.find("my.gauge").gauge();
    assertThat(meterRegistry.writeGauge(gauge)).isEmpty();
}
Also used : Gauge(io.micrometer.core.instrument.Gauge) TimeGauge(io.micrometer.core.instrument.TimeGauge) Test(org.junit.jupiter.api.Test)

Example 17 with Gauge

use of io.micrometer.core.instrument.Gauge in project micrometer by micrometer-metrics.

the class KairosMeterRegistryTest method writeGauge.

@Test
void writeGauge() {
    meterRegistry.gauge("my.gauge", 1d);
    Gauge gauge = meterRegistry.find("my.gauge").gauge();
    assertThat(meterRegistry.writeGauge(gauge)).hasSize(1);
}
Also used : Gauge(io.micrometer.core.instrument.Gauge) TimeGauge(io.micrometer.core.instrument.TimeGauge) Test(org.junit.jupiter.api.Test)

Example 18 with Gauge

use of io.micrometer.core.instrument.Gauge in project micrometer by micrometer-metrics.

the class MetricSchemaCompatibilityTest method semanticMetricTypes.

/**
 * Assuring that when the configuration flag useSemanticMetricTypes is set,
 * metric types matching their meaning are used.
 */
@Test
void semanticMetricTypes() {
    config.put("stackdriver.useSemanticMetricTypes", "true");
    assertSchemaCompatibility(Collections.singletonList(new Pair(GAUGE, DOUBLE)), registry.createGauge(batch, Gauge.builder("gauge", () -> 1).register(registry)));
    assertSchemaCompatibility(Collections.singletonList(new Pair(CUMULATIVE, DOUBLE)), registry.createCounter(batch, Counter.builder("counter").register(registry)));
    assertSchemaCompatibility(Arrays.asList(new Pair(GAUGE, DISTRIBUTION), new Pair(GAUGE, DOUBLE), new Pair(CUMULATIVE, INT64)), registry.createTimer(batch, Timer.builder("timer").register(registry)));
    assertSchemaCompatibility(Arrays.asList(new Pair(GAUGE, DISTRIBUTION), new Pair(GAUGE, DOUBLE), new Pair(CUMULATIVE, INT64)), registry.createSummary(batch, DistributionSummary.builder("summary").register(registry)));
    assertSchemaCompatibility(Arrays.asList(new Pair(GAUGE, INT64), new Pair(GAUGE, DOUBLE)), registry.createLongTaskTimer(batch, LongTaskTimer.builder("longTaskTimer").register(registry)));
    assertSchemaCompatibility(Collections.singletonList(new Pair(GAUGE, DOUBLE)), registry.createTimeGauge(batch, TimeGauge.builder("timeGauge", () -> 1, TimeUnit.SECONDS).register(registry)));
    assertSchemaCompatibility(Collections.singletonList(new Pair(CUMULATIVE, DOUBLE)), registry.createFunctionCounter(batch, FunctionCounter.builder("functionCounter", 1, value -> 1).register(registry)));
    assertSchemaCompatibility(Collections.singletonList(new Pair(GAUGE, DISTRIBUTION)), registry.createFunctionTimer(batch, FunctionTimer.builder("functionTimer", 1, value -> 1, value -> 1, TimeUnit.SECONDS).register(registry)));
    assertSchemaCompatibility(Collections.singletonList(new Pair(GAUGE, DOUBLE)), registry.createMeter(batch, Meter.builder("gauge", Meter.Type.OTHER, Collections.singletonList(new Measurement(() -> 1.0, Statistic.UNKNOWN))).register(registry)));
}
Also used : Statistic(io.micrometer.core.instrument.Statistic) LongTaskTimer(io.micrometer.core.instrument.LongTaskTimer) Arrays(java.util.Arrays) MockClock(io.micrometer.core.instrument.MockClock) MetricDescriptor(com.google.api.MetricDescriptor) HashMap(java.util.HashMap) TimeGauge(io.micrometer.core.instrument.TimeGauge) MetricKind(com.google.api.MetricDescriptor.MetricKind) Timer(io.micrometer.core.instrument.Timer) ValueType(com.google.api.MetricDescriptor.ValueType) Map(java.util.Map) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Counter(io.micrometer.core.instrument.Counter) Gauge(io.micrometer.core.instrument.Gauge) TimeSeries(com.google.monitoring.v3.TimeSeries) Meter(io.micrometer.core.instrument.Meter) Collectors(java.util.stream.Collectors) FunctionTimer(io.micrometer.core.instrument.FunctionTimer) Measurement(io.micrometer.core.instrument.Measurement) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) List(java.util.List) Stream(java.util.stream.Stream) DistributionSummary(io.micrometer.core.instrument.DistributionSummary) FunctionCounter(io.micrometer.core.instrument.FunctionCounter) Collections(java.util.Collections) Measurement(io.micrometer.core.instrument.Measurement) Test(org.junit.jupiter.api.Test)

Example 19 with Gauge

use of io.micrometer.core.instrument.Gauge in project micrometer by micrometer-metrics.

the class HumioMeterRegistryTest method writeGaugeShouldDropPositiveInfiniteValue.

@Test
void writeGaugeShouldDropPositiveInfiniteValue() {
    meterRegistry.gauge("my.gauge", Double.POSITIVE_INFINITY);
    Gauge gauge = meterRegistry.find("my.gauge").gauge();
    assertThat(createBatch().writeGauge(gauge)).isNull();
}
Also used : Gauge(io.micrometer.core.instrument.Gauge) TimeGauge(io.micrometer.core.instrument.TimeGauge) Test(org.junit.jupiter.api.Test)

Example 20 with Gauge

use of io.micrometer.core.instrument.Gauge in project micrometer by micrometer-metrics.

the class HumioMeterRegistryTest method writeGauge.

@Test
void writeGauge() {
    meterRegistry.gauge("my.gauge", 1d);
    Gauge gauge = meterRegistry.find("my.gauge").gauge();
    assertThat(createBatch().writeGauge(gauge)).isNotNull();
}
Also used : Gauge(io.micrometer.core.instrument.Gauge) TimeGauge(io.micrometer.core.instrument.TimeGauge) Test(org.junit.jupiter.api.Test)

Aggregations

Gauge (io.micrometer.core.instrument.Gauge)43 Test (org.junit.jupiter.api.Test)27 TimeGauge (io.micrometer.core.instrument.TimeGauge)16 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)10 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)9 FunctionCounter (io.micrometer.core.instrument.FunctionCounter)7 Meter (io.micrometer.core.instrument.Meter)7 DistributionSummary (io.micrometer.core.instrument.DistributionSummary)6 FunctionTimer (io.micrometer.core.instrument.FunctionTimer)6 Timer (io.micrometer.core.instrument.Timer)6 Counter (io.micrometer.core.instrument.Counter)5 LongTaskTimer (io.micrometer.core.instrument.LongTaskTimer)5 TimeUnit (java.util.concurrent.TimeUnit)5 Test (org.junit.Test)5 Issue (io.micrometer.core.Issue)4 Measurement (io.micrometer.core.instrument.Measurement)4 MockClock (io.micrometer.core.instrument.MockClock)4 AbstractCacheMetricsTest (io.micrometer.core.instrument.binder.cache.AbstractCacheMetricsTest)4 Statistic (io.micrometer.core.instrument.Statistic)3 Arrays (java.util.Arrays)3