Search in sources :

Example 1 with Gauge

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

the class JmxReporterTest method registersMBeansForMetricObjectsUsingProvidedObjectNameFactory.

@Test
public void registersMBeansForMetricObjectsUsingProvidedObjectNameFactory() throws Exception {
    ObjectName n = new ObjectName(name + ":name=dummy");
    try {
        String widgetName = "something";
        when(mockObjectNameFactory.createName(any(String.class), any(String.class), any(MetricName.class))).thenReturn(n);
        Gauge aGauge = mock(Gauge.class);
        when(aGauge.getValue()).thenReturn(1);
        JmxReporter reporter = JmxReporter.forRegistry(registry).registerWith(mBeanServer).inDomain(name).createsObjectNamesWith(mockObjectNameFactory).build();
        registry.register(widgetName, aGauge);
        reporter.start();
        verify(mockObjectNameFactory).createName(eq("gauges"), any(String.class), eq(MetricName.build("something")));
    // verifyNoMoreInteractions(mockObjectNameFactory);
    } finally {
        reporter.stop();
        if (mBeanServer.isRegistered(n)) {
            mBeanServer.unregisterMBean(n);
        }
    }
}
Also used : MetricName(io.dropwizard.metrics.MetricName) JmxReporter(io.dropwizard.metrics.JmxReporter) Gauge(io.dropwizard.metrics.Gauge) Test(org.junit.Test)

Example 2 with Gauge

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

the class JvmAttributeGaugeSetTest method hasAGaugeForTheJVMVendor.

@Test
public void hasAGaugeForTheJVMVendor() throws Exception {
    final Gauge gauge = (Gauge) gauges.getMetrics().get(MetricName.build("vendor"));
    assertThat(gauge.getValue()).isEqualTo("Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 23.7-b01 (1.7)");
}
Also used : Gauge(io.dropwizard.metrics.Gauge) Test(org.junit.Test)

Example 3 with Gauge

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

the class JvmAttributeGaugeSetTest method autoDiscoversTheRuntimeBean.

@Test
public void autoDiscoversTheRuntimeBean() throws Exception {
    final Gauge gauge = (Gauge) new JvmAttributeGaugeSet().getMetrics().get(MetricName.build("uptime"));
    assertThat((Long) gauge.getValue()).isPositive();
}
Also used : JvmAttributeGaugeSet(io.dropwizard.metrics.JvmAttributeGaugeSet) Gauge(io.dropwizard.metrics.Gauge) Test(org.junit.Test)

Example 4 with Gauge

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

the class JvmAttributeGaugeSetTest method hasAGaugeForTheJVMName.

@Test
public void hasAGaugeForTheJVMName() throws Exception {
    final Gauge gauge = (Gauge) gauges.getMetrics().get(MetricName.build("name"));
    assertThat(gauge.getValue()).isEqualTo("9928@example.com");
}
Also used : Gauge(io.dropwizard.metrics.Gauge) Test(org.junit.Test)

Example 5 with Gauge

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

the class Slf4jReporterTest method gauge.

private <T> Gauge gauge(T value) {
    final Gauge gauge = mock(Gauge.class);
    when(gauge.getValue()).thenReturn(value);
    return gauge;
}
Also used : Gauge(io.dropwizard.metrics.Gauge)

Aggregations

Gauge (io.dropwizard.metrics.Gauge)9 Test (org.junit.Test)6 MetricName (io.dropwizard.metrics.MetricName)2 Counter (io.dropwizard.metrics.Counter)1 Histogram (io.dropwizard.metrics.Histogram)1 JmxReporter (io.dropwizard.metrics.JmxReporter)1 JvmAttributeGaugeSet (io.dropwizard.metrics.JvmAttributeGaugeSet)1 Meter (io.dropwizard.metrics.Meter)1 Timer (io.dropwizard.metrics.Timer)1