use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.
the class JsonExporterGetTest method multipeRepositoriesAreGroupedByNameMetricOption.
@Test
public void multipeRepositoriesAreGroupedByNameMetricOption() {
exporter = exporter.in(Type.BASE);
Gauge<Long> fooVal = () -> 1L;
MetricID fooValID = new MetricID("fooVal", new Tag("store", "webshop"));
export(fooValID, fooVal);
exporter = exporter.in(Type.APPLICATION);
export(fooValID, fooVal);
assertOutputEquals("\n" + "{\n" + " \"base\": {\n" + " \"fooVal;store=webshop\": 1\n" + " },\n" + " \"application\": {\n" + " \"fooVal;store=webshop\": 1\n" + " }\n" + "}");
}
use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.
the class JsonExporterGetTest method exportConcurrentGauge.
@Test
public void exportConcurrentGauge() {
ConcurrentGauge callCount = mock(ConcurrentGauge.class);
when(callCount.getCount()).thenReturn(48L);
when(callCount.getMin()).thenReturn(4L);
when(callCount.getMax()).thenReturn(50L);
ConcurrentGauge callCount2 = mock(ConcurrentGauge.class);
when(callCount2.getCount()).thenReturn(23L);
when(callCount2.getMin()).thenReturn(1L);
when(callCount2.getMax()).thenReturn(29L);
export(new MetricID("callCount"), callCount);
export(new MetricID("callCount", new Tag("component", "backend")), callCount2);
assertOutputEqualsFile("ConcurrentGauge.json");
}
use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.
the class JsonExporterGetTest method gaugesThatThrowIllegalStateExceptionWhenReadAreNotExported.
@Test
public void gaugesThatThrowIllegalStateExceptionWhenReadAreNotExported() {
Gauge<Long> gauge = () -> {
throw new IllegalStateException("test");
};
MetricID metricID = new MetricID("test4");
Metadata metadata = Metadata.builder().withName(metricID.getName()).build();
assertOutputEquals("\n{\n}", metricID, gauge, metadata);
}
use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.
the class JsonExporterGetTest method exportMeter.
@Test
public void exportMeter() {
Meter requests = mock(Meter.class);
when(requests.getCount()).thenReturn(29382L);
when(requests.getMeanRate()).thenReturn(12.223d);
when(requests.getOneMinuteRate()).thenReturn(12.563d);
when(requests.getFiveMinuteRate()).thenReturn(12.364d);
when(requests.getFifteenMinuteRate()).thenReturn(12.126d);
// example uses same values for all three meters so we can get away with just one
// but conceptually those should be three different meter instances
export(new MetricID("requests"), requests);
export(new MetricID("requests", new Tag("servlet", "one")), requests);
export(new MetricID("requests", new Tag("servlet", "two")), requests);
assertOutputEqualsFile("Meter.json");
}
use of org.eclipse.microprofile.metrics.MetricID in project Payara by payara.
the class JsonExporterGetTest method gaugesWithNonNumberValuesAreNotExported.
/*
* Below tests are no examples from the specification
*/
@Test
public void gaugesWithNonNumberValuesAreNotExported() {
Gauge<String> gauge = () -> "hello world";
MetricID metricID = new MetricID("test3");
Metadata metadata = Metadata.builder().withName(metricID.getName()).build();
assertOutputEquals("\n{\n}", metricID, gauge, metadata);
}
Aggregations