use of org.eclipse.microprofile.metrics.MetricID 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.MetricID 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.MetricID in project Payara by payara.
the class MetricRegistryImplTest method registerByMetadataAllowsToRegisterMetricsOfSameNameWithDifferentTagsButSameType.
@Test
public void registerByMetadataAllowsToRegisterMetricsOfSameNameWithDifferentTagsButSameType() {
String name = nextName();
Tag ab = new Tag("a", "b");
Tag ac = new Tag("a", "c");
MetricID metricAb = new MetricID(name, ab);
MetricID metricAc = new MetricID(name, ac);
registry.register(withName(name), new TimerImpl(), ab);
registry.register(withName(name), new TimerImpl(), ac);
assertEquals(2, registry.getTimers().size());
Map<MetricID, Metric> metrics = registry.getMetrics((metricID, metric) -> metricID.getName().equals(name));
assertEquals(2, metrics.size());
assertTrue(metrics.containsKey(metricAb));
assertTrue(metrics.containsKey(metricAc));
assertEquals(new TreeSet<>(asList(metricAb, metricAc)), registry.getMetricIDs());
assertEquals(new TreeSet<>(asList(name)), registry.getNames());
assertEquals(1, registry.getTimers((id, metric) -> id.equals(metricAc)).size());
}
use of org.eclipse.microprofile.metrics.MetricID 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.MetricID 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