Search in sources :

Example 1 with TimerImpl

use of fish.payara.microprofile.metrics.impl.TimerImpl 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());
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) Metric(org.eclipse.microprofile.metrics.Metric) Tag(org.eclipse.microprofile.metrics.Tag) TimerImpl(fish.payara.microprofile.metrics.impl.TimerImpl) Test(org.junit.Test)

Aggregations

TimerImpl (fish.payara.microprofile.metrics.impl.TimerImpl)1 Metric (org.eclipse.microprofile.metrics.Metric)1 MetricID (org.eclipse.microprofile.metrics.MetricID)1 Tag (org.eclipse.microprofile.metrics.Tag)1 Test (org.junit.Test)1