Search in sources :

Example 1 with Meter

use of org.apache.sling.commons.metrics.Meter in project sling by apache.

the class MetricServiceTest method jmxRegistration.

@Test
public void jmxRegistration() throws Exception {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    activate();
    Meter meter = service.meter("test");
    assertNotNull(meter);
    QueryExp q = Query.isInstanceOf(Query.value(JmxReporter.JmxMeterMBean.class.getName()));
    Set<ObjectName> names = server.queryNames(new ObjectName("org.apache.sling:name=*,type=" + JMX_TYPE_METRICS), q);
    assertThat(names, is(not(empty())));
    MockOsgi.deactivate(service, context.bundleContext());
    names = server.queryNames(new ObjectName("org.apache.sling:name=*"), q);
    assertThat(names, is(empty()));
}
Also used : Meter(org.apache.sling.commons.metrics.Meter) QueryExp(javax.management.QueryExp) JmxReporter(com.codahale.metrics.JmxReporter) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 2 with Meter

use of org.apache.sling.commons.metrics.Meter in project sling by apache.

the class MetricServiceTest method meter.

@Test
public void meter() throws Exception {
    activate();
    Meter meter = service.meter("test");
    assertNotNull(meter);
    assertTrue(getRegistry().getMeters().containsKey("test"));
    assertSame(meter, service.meter("test"));
}
Also used : Meter(org.apache.sling.commons.metrics.Meter) Test(org.junit.Test)

Aggregations

Meter (org.apache.sling.commons.metrics.Meter)2 Test (org.junit.Test)2 JmxReporter (com.codahale.metrics.JmxReporter)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 QueryExp (javax.management.QueryExp)1