Search in sources :

Example 6 with MetricName

use of io.dropwizard.metrics.MetricName 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

MetricName (io.dropwizard.metrics.MetricName)6 HashMap (java.util.HashMap)3 Test (org.junit.Test)3 MetricSet (io.dropwizard.metrics.MetricSet)2 Map (java.util.Map)2 Counter (io.dropwizard.metrics.Counter)1 Gauge (io.dropwizard.metrics.Gauge)1 Histogram (io.dropwizard.metrics.Histogram)1 Meter (io.dropwizard.metrics.Meter)1 Timer (io.dropwizard.metrics.Timer)1