Search in sources :

Example 21 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class OpenMetricsExporterTest method unitNoneShouldNotBeAppendedToName.

@Test
public void unitNoneShouldNotBeAppendedToName() {
    Gauge<Long> gauge = () -> 13L;
    MetricID metricID = new MetricID("test2");
    Metadata metadata = Metadata.builder().withName(metricID.getName()).withUnit(MetricUnits.NONE).build();
    assertOutputEquals("# TYPE application_test2 gauge\n" + "application_test2 13\n", metricID, gauge, metadata);
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) Metadata(org.eclipse.microprofile.metrics.Metadata) Test(org.junit.Test)

Example 22 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class OpenMetricsExporterTest method unitPercentMappedToRatioWithUnscaledValue.

@Test
public void unitPercentMappedToRatioWithUnscaledValue() {
    Gauge<Double> perSec = () -> 2.3d;
    MetricID metricID = new MetricID("test8");
    Metadata metadata = Metadata.builder().withName(metricID.getName()).withUnit(MetricUnits.PERCENT).build();
    assertOutputEquals("# TYPE application_test8_ratio gauge\n" + "application_test8_ratio 2.3\n", metricID, perSec, metadata);
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) Metadata(org.eclipse.microprofile.metrics.Metadata) Test(org.junit.Test)

Example 23 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class OpenMetricsExporterTest method exportSimpleTimer.

@Test
public void exportSimpleTimer() {
    SimpleTimer timer = mock(SimpleTimer.class);
    when(timer.getCount()).thenReturn(12L);
    when(timer.getElapsedTime()).thenReturn(Duration.ofMillis(12300L));
    when(timer.getMaxTimeDuration()).thenReturn(Duration.ofMillis(3231L));
    when(timer.getMinTimeDuration()).thenReturn(Duration.ofNanos(25600000L));
    MetricID metricID = new MetricID("response_time");
    Metadata metadata = Metadata.builder().withName(metricID.getName()).withDescription("The number of calls to this REST endpoint #(1)").build();
    assertOutputEqualsFile("SimpleTimer.txt", metricID, timer, metadata);
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) SimpleTimer(org.eclipse.microprofile.metrics.SimpleTimer) Metadata(org.eclipse.microprofile.metrics.Metadata) Test(org.junit.Test)

Example 24 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class OpenMetricsExporterTest method unitOfStyleA_Per_BAreKeptWithUnscaledValue.

@Test
public void unitOfStyleA_Per_BAreKeptWithUnscaledValue() {
    Gauge<Double> aPerB = () -> 2.3d;
    MetricID metricID = new MetricID("test9");
    Metadata metadata = Metadata.builder().withName(metricID.getName()).withUnit("meter_per_sec").build();
    assertOutputEquals("# TYPE application_test9_meter_per_sec gauge\n" + "application_test9_meter_per_sec 2.3\n", metricID, aPerB, metadata);
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) Metadata(org.eclipse.microprofile.metrics.Metadata) Test(org.junit.Test)

Example 25 with MetricID

use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.

the class OpenMetricsExporterTest method tagValuesAreEscaped.

@Test
public void tagValuesAreEscaped() {
    Counter counter = mock(Counter.class);
    when(counter.getCount()).thenReturn(13L);
    MetricID metricID = new MetricID("test5", new Tag("key", "escape\\and\"and\n"));
    Metadata metadata = Metadata.builder().withName(metricID.getName()).build();
    assertOutputEquals("# TYPE application_test5_total counter\n" + "application_test5_total{key=\"escape\\\\and\\\"and\\n\"} 13\n", metricID, counter, metadata);
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) Counter(org.eclipse.microprofile.metrics.Counter) Metadata(org.eclipse.microprofile.metrics.Metadata) Tag(org.eclipse.microprofile.metrics.Tag) Test(org.junit.Test)

Aggregations

MetricID (org.eclipse.microprofile.metrics.MetricID)53 Test (org.junit.Test)41 Metadata (org.eclipse.microprofile.metrics.Metadata)31 Tag (org.eclipse.microprofile.metrics.Tag)25 Counter (org.eclipse.microprofile.metrics.Counter)10 Metric (org.eclipse.microprofile.metrics.Metric)6 SimpleTimer (org.eclipse.microprofile.metrics.SimpleTimer)6 Snapshot (org.eclipse.microprofile.metrics.Snapshot)6 Histogram (org.eclipse.microprofile.metrics.Histogram)5 ConcurrentGauge (org.eclipse.microprofile.metrics.ConcurrentGauge)4 Timer (org.eclipse.microprofile.metrics.Timer)4 Gauge (org.eclipse.microprofile.metrics.Gauge)3 MonitoringDataCollector (fish.payara.monitoring.collect.MonitoringDataCollector)2 ArrayList (java.util.ArrayList)2 Meter (org.eclipse.microprofile.metrics.Meter)2 NoSuchRegistryException (fish.payara.microprofile.metrics.exception.NoSuchRegistryException)1 TimerImpl (fish.payara.microprofile.metrics.impl.TimerImpl)1 MBeanMetadata (fish.payara.microprofile.metrics.jmx.MBeanMetadata)1 FileNotFoundException (java.io.FileNotFoundException)1 Collections.emptyMap (java.util.Collections.emptyMap)1