use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class OpenMetricsExporterTest method assertUnitConversion.
private void assertUnitConversion(String inputUnit, Number inputValue, String expectedUnit, String expectedValue) {
Gauge<Number> gauge = () -> inputValue;
String name = "test" + nextNameId.incrementAndGet();
MetricID metricID = new MetricID(name);
Metadata metadata = Metadata.builder().withName(metricID.getName()).withUnit(inputUnit).build();
assertOutputEquals("# TYPE application_" + name + "_" + expectedUnit + " gauge\n" + "application_" + name + "_" + expectedUnit + " " + expectedValue + "\n", metricID, gauge, metadata);
// clean output so far to allow multiple usages of this in a single test
actual.getBuffer().setLength(0);
}
use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class OpenMetricsExporterTest method exportConcurrentGauge.
@Test
public void exportConcurrentGauge() {
ConcurrentGauge gauge = mock(ConcurrentGauge.class);
when(gauge.getCount()).thenReturn(80L);
when(gauge.getMin()).thenReturn(20L);
when(gauge.getMax()).thenReturn(100L);
MetricID metricID = new MetricID("method_a_invocations");
Metadata metadata = Metadata.builder().withName(metricID.getName()).withDescription("The number of parallel invocations of methodA()").build();
assertOutputEqualsFile("ConcurrentGauge.txt", metricID, gauge, metadata);
}
use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class OpenMetricsExporterTest method exportTimer.
@Test
public void exportTimer() {
Timer timer = mock(Timer.class);
when(timer.getElapsedTime()).thenReturn(Duration.ofMillis(23L));
when(timer.getCount()).thenReturn(80L);
when(timer.getMeanRate()).thenReturn(0.004292520715985437d);
when(timer.getOneMinuteRate()).thenReturn(2.794076465421066E-14d);
when(timer.getFiveMinuteRate()).thenReturn(4.800392614619373E-4d);
when(timer.getFifteenMinuteRate()).thenReturn(0.01063191047532505d);
Snapshot snapshot = mock(Snapshot.class);
when(timer.getSnapshot()).thenReturn(snapshot);
when(snapshot.getMin()).thenReturn(169916L);
when(snapshot.getMax()).thenReturn(560869L);
when(snapshot.getMean()).thenReturn(415041d);
when(snapshot.getStdDev()).thenReturn(652907d);
when(snapshot.getMedian()).thenReturn(293324d);
when(snapshot.get75thPercentile()).thenReturn(344914d);
when(snapshot.get95thPercentile()).thenReturn(543647d);
when(snapshot.get98thPercentile()).thenReturn(2706543d);
when(snapshot.get99thPercentile()).thenReturn(5608694d);
when(snapshot.get999thPercentile()).thenReturn(5608694d);
MetricID metricID = new MetricID("response_time");
Metadata metadata = Metadata.builder().withName(metricID.getName()).withDescription("Server response time for /index.html").withUnit(MetricUnits.NANOSECONDS).build();
assertOutputEqualsFile("Timer.txt", metricID, timer, metadata);
}
use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class OpenMetricsExporterTest method exportMeter.
@Test
public void exportMeter() {
Meter meter = mock(Meter.class);
when(meter.getCount()).thenReturn(29382L);
when(meter.getMeanRate()).thenReturn(12.223d);
when(meter.getOneMinuteRate()).thenReturn(12.563d);
when(meter.getFiveMinuteRate()).thenReturn(12.364d);
when(meter.getFifteenMinuteRate()).thenReturn(12.126d);
MetricID metricID = new MetricID("requests");
Metadata metadata = Metadata.builder().withName(metricID.getName()).withDescription("Tracks the number of requests to the server").build();
assertOutputEqualsFile("Meter.txt", metricID, meter, metadata);
}
use of org.eclipse.microprofile.metrics.Metadata in project Payara by payara.
the class OpenMetricsExporterTest method emptyDescriptionDoesNotPrintHelpLine.
@Test
public void emptyDescriptionDoesNotPrintHelpLine() {
Counter counter = mock(Counter.class);
when(counter.getCount()).thenReturn(13L);
MetricID metricID = new MetricID("test1");
Metadata metadata = Metadata.builder().withName(metricID.getName()).withDescription("").build();
assertOutputEquals("# TYPE application_test1_total counter\n" + "application_test1_total 13\n", metricID, counter, metadata);
}
Aggregations