Search in sources :

Example 16 with Metadata

use of org.eclipse.microprofile.metrics.Metadata 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 17 with Metadata

use of org.eclipse.microprofile.metrics.Metadata 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 18 with Metadata

use of org.eclipse.microprofile.metrics.Metadata 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 19 with Metadata

use of org.eclipse.microprofile.metrics.Metadata 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 20 with Metadata

use of org.eclipse.microprofile.metrics.Metadata 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

Metadata (org.eclipse.microprofile.metrics.Metadata)65 MetricID (org.eclipse.microprofile.metrics.MetricID)31 Test (org.junit.Test)30 Tag (org.eclipse.microprofile.metrics.Tag)12 Counter (org.eclipse.microprofile.metrics.Counter)9 Metric (org.eclipse.microprofile.metrics.Metric)9 MetricRegistry (org.eclipse.microprofile.metrics.MetricRegistry)8 HashMap (java.util.HashMap)6 Map (java.util.Map)4 Histogram (org.eclipse.microprofile.metrics.Histogram)4 ArrayList (java.util.ArrayList)3 Meter (org.eclipse.microprofile.metrics.Meter)3 Gauge (org.eclipse.microprofile.metrics.annotation.Gauge)3 ObjectName (javax.management.ObjectName)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Gauge (org.eclipse.microprofile.metrics.Gauge)2 MetricType (org.eclipse.microprofile.metrics.MetricType)2 SimpleTimer (org.eclipse.microprofile.metrics.SimpleTimer)2 Snapshot (org.eclipse.microprofile.metrics.Snapshot)2