Search in sources :

Example 1 with MetricSet

use of io.dropwizard.metrics.MetricSet in project light-4j by networknt.

the class MetricRegistryTest method registersMultipleMetrics.

@Test
public void registersMultipleMetrics() throws Exception {
    final MetricSet metrics = () -> {
        final Map<MetricName, Metric> metrics1 = new HashMap<>();
        metrics1.put(GAUGE2, gauge);
        metrics1.put(COUNTER2, counter);
        return metrics1;
    };
    registry.registerAll(metrics);
    assertThat(registry.getNames()).containsOnly(GAUGE2, COUNTER2);
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) MetricSet(io.dropwizard.metrics.MetricSet) Test(org.junit.Test)

Example 2 with MetricSet

use of io.dropwizard.metrics.MetricSet in project light-4j by networknt.

the class MetricRegistryTest method registersMultipleMetricsWithAPrefix.

@Test
public void registersMultipleMetricsWithAPrefix() throws Exception {
    final MetricName myCounter = MetricName.build("my.counter");
    final MetricName myGauge = MetricName.build("my.gauge");
    final MetricSet metrics = () -> {
        final Map<MetricName, Metric> metrics1 = new HashMap<>();
        metrics1.put(GAUGE, gauge);
        metrics1.put(COUNTER, counter);
        return metrics1;
    };
    registry.register("my", metrics);
    assertThat(registry.getNames()).containsOnly(myGauge, myCounter);
}
Also used : MetricName(io.dropwizard.metrics.MetricName) HashMap(java.util.HashMap) Map(java.util.Map) MetricSet(io.dropwizard.metrics.MetricSet) Test(org.junit.Test)

Example 3 with MetricSet

use of io.dropwizard.metrics.MetricSet in project light-4j by networknt.

the class MetricRegistryTest method registersRecursiveMetricSets.

@Test
public void registersRecursiveMetricSets() throws Exception {
    final MetricSet inner = () -> {
        final Map<MetricName, Metric> metrics = new HashMap<>();
        metrics.put(GAUGE, gauge);
        return metrics;
    };
    final MetricSet outer = () -> {
        final Map<MetricName, Metric> metrics = new HashMap<>();
        metrics.put(MetricName.build("inner"), inner);
        metrics.put(COUNTER, counter);
        return metrics;
    };
    registry.register("my", outer);
    final MetricName myCounter = MetricName.build("my.counter");
    final MetricName myInnerGauge = MetricName.build("my.inner.gauge");
    assertThat(registry.getNames()).containsOnly(myInnerGauge, myCounter);
}
Also used : MetricName(io.dropwizard.metrics.MetricName) HashMap(java.util.HashMap) Map(java.util.Map) MetricSet(io.dropwizard.metrics.MetricSet) Test(org.junit.Test)

Aggregations

MetricSet (io.dropwizard.metrics.MetricSet)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Test (org.junit.Test)3 MetricName (io.dropwizard.metrics.MetricName)2