com.codahale.metrics.MetricRegistryListener Java Examples

The following examples show how to use com.codahale.metrics.MetricRegistryListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScopedMetricRegistryTest.java    From styx with Apache License 2.0 5 votes vote down vote up
@Test
public void scopesMetricsBeforeDelegatingToUnderlyingMetricRegistry() {
    MetricRegistry metricRegistry = mock(MetricRegistry.class);
    MetricRegistry scopedMetricRegistry = new ScopedMetricRegistry("scope", metricRegistry);

    scopedMetricRegistry.counter("counter");
    verify(metricRegistry).counter("scope.counter");

    scopedMetricRegistry.meter("meter");
    verify(metricRegistry).meter("scope.meter");

    scopedMetricRegistry.histogram("histogram");
    verify(metricRegistry).histogram("scope.histogram");

    scopedMetricRegistry.timer("timer");
    verify(metricRegistry).timer("scope.timer");

    Metric metric = new Counter();
    scopedMetricRegistry.register("register.counter", metric);
    verify(metricRegistry).register("scope.register.counter", metric);

    scopedMetricRegistry.deregister("register.counter");
    verify(metricRegistry).deregister("scope.register.counter");

    MetricRegistryListener listener = mock(MetricRegistryListener.class);

    scopedMetricRegistry.addListener(listener);
    verify(metricRegistry).addListener(listener);

    scopedMetricRegistry.removeListener(listener);
    verify(metricRegistry).removeListener(listener);
}
 
Example #2
Source File: JVMMetricsHandler.java    From styx with Apache License 2.0 4 votes vote down vote up
@Override
public void addListener(MetricRegistryListener listener) {
}
 
Example #3
Source File: JVMMetricsHandler.java    From styx with Apache License 2.0 4 votes vote down vote up
@Override
public void removeListener(MetricRegistryListener listener) {
}
 
Example #4
Source File: CodaHaleMetricRegistry.java    From styx with Apache License 2.0 4 votes vote down vote up
@Override
public void addListener(MetricRegistryListener listener) {
    this.metricRegistry.addListener(listener);
}
 
Example #5
Source File: CodaHaleMetricRegistry.java    From styx with Apache License 2.0 4 votes vote down vote up
@Override
public void removeListener(MetricRegistryListener listener) {
    this.metricRegistry.removeListener(listener);
}
 
Example #6
Source File: ScopedMetricRegistry.java    From styx with Apache License 2.0 4 votes vote down vote up
@Override
public void addListener(MetricRegistryListener listener) {
    this.parent.addListener(listener);
}
 
Example #7
Source File: ScopedMetricRegistry.java    From styx with Apache License 2.0 4 votes vote down vote up
@Override
public void removeListener(MetricRegistryListener listener) {
    this.parent.removeListener(listener);
}
 
Example #8
Source File: CodaHaleMetricRegistryTest.java    From styx with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setUp() {
    this.metricRegistry = new CodaHaleMetricRegistry(new com.codahale.metrics.MetricRegistry());
    this.listener = mock(MetricRegistryListener.class);
}
 
Example #9
Source File: MetricRegistry.java    From styx with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a {@link MetricRegistryListener} to a collection of listeners that will be notified on
 * metric creation.  Listeners will be notified in the order in which they are added.
 * <p/>
 * <b>N.B.:</b> The listener will be notified of all existing metrics when it first registers.
 *
 * @param listener the listener that will be notified
 */
void addListener(MetricRegistryListener listener);
 
Example #10
Source File: MetricRegistry.java    From styx with Apache License 2.0 2 votes vote down vote up
/**
 * Removes a {@link MetricRegistryListener} from this registry's collection of listeners.
 *
 * @param listener the listener that will be removed
 */
void removeListener(MetricRegistryListener listener);