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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations