Search in sources :

Example 1 with ConcurrentGauge

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");
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) ConcurrentGauge(org.eclipse.microprofile.metrics.ConcurrentGauge) Tag(org.eclipse.microprofile.metrics.Tag) Test(org.junit.Test)

Example 2 with ConcurrentGauge

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);
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) ConcurrentGauge(org.eclipse.microprofile.metrics.ConcurrentGauge) Metadata(org.eclipse.microprofile.metrics.Metadata) Test(org.junit.Test)

Example 3 with ConcurrentGauge

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());
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) ConcurrentGauge(org.eclipse.microprofile.metrics.ConcurrentGauge) Test(org.junit.Test)

Aggregations

ConcurrentGauge (org.eclipse.microprofile.metrics.ConcurrentGauge)3 MetricID (org.eclipse.microprofile.metrics.MetricID)3 Test (org.junit.Test)3 Metadata (org.eclipse.microprofile.metrics.Metadata)1 Tag (org.eclipse.microprofile.metrics.Tag)1