use of org.eclipse.microprofile.metrics.ConcurrentGauge 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.ConcurrentGauge 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.ConcurrentGauge in project Payara by payara.
the class MetricRegistryImplTest method removeByMetricIdRemovesOnlyMetricsWithThatId.
@Test
public void removeByMetricIdRemovesOnlyMetricsWithThatId() {
String name = nextName();
registry.concurrentGauge(withName(name));
ConcurrentGauge remaining1 = registry.concurrentGauge(withName(name), SOME_TAG);
String otherName = nextName();
ConcurrentGauge remaining2 = registry.concurrentGauge(withName(otherName));
assertEquals(3, registry.getConcurrentGauges().size());
assertEquals(new TreeSet<>(asList(name, otherName)), registry.getNames());
assertTrue(registry.remove(new MetricID(name)));
assertEquals(2, registry.getConcurrentGauges().size());
assertEquals(new HashSet<>(asList(remaining1, remaining2)), new HashSet<>(registry.getConcurrentGauges().values()));
assertEquals(new TreeSet<>(asList(name, otherName)), registry.getNames());
assertTrue(registry.remove(new MetricID(name, SOME_TAG)));
assertEquals(1, registry.getConcurrentGauges().size());
assertEquals(new TreeSet<>(asList(otherName)), registry.getNames());
}
Aggregations