use of com.hazelcast.internal.metrics.collectors.MetricsCollector in project hazelcast by hazelcast.
the class DynamicMetricsCollectionTest method testExtractingFromObjectProveLevelFilters.
@Test
public void testExtractingFromObjectProveLevelFilters() {
SourceObject source = new SourceObject();
source.longField = 42;
source.doubleField = 42.42D;
MetricsCollector collectorMock = mock(MetricsCollector.class);
MetricsRegistry registry = new MetricsRegistryImpl(Logger.getLogger(MetricsRegistryImpl.class), MANDATORY);
registry.registerDynamicMetricsProvider((descriptor, context) -> context.collect(descriptor.withPrefix("test"), source));
registry.collect(collectorMock);
verify(collectorMock, never()).collectLong(registry.newMetricDescriptor().withPrefix("test").withMetric("longField"), 42);
verify(collectorMock, never()).collectDouble(registry.newMetricDescriptor().withPrefix("test").withMetric("doubleField"), 42.42D);
verify(collectorMock, never()).collectLong(registry.newMetricDescriptor().withPrefix("test").withMetric("longMethod"), 43);
verify(collectorMock, never()).collectDouble(registry.newMetricDescriptor().withPrefix("test").withMetric("doubleMethod"), 43.52D);
}
use of com.hazelcast.internal.metrics.collectors.MetricsCollector in project hazelcast by hazelcast.
the class RenderTest method whenException.
@Test
public void whenException() {
MetricsCollector renderer = mock(MetricsCollector.class);
final ExpectedRuntimeException ex = new ExpectedRuntimeException();
metricsRegistry.registerStaticProbe(this, "foo", ProbeLevel.MANDATORY, (LongProbeFunction<RenderTest>) source -> {
throw ex;
});
metricsRegistry.collect(renderer);
verify(renderer).collectException(metricDescriptor("foo"), ex);
verifyNoMoreInteractions(renderer);
}
use of com.hazelcast.internal.metrics.collectors.MetricsCollector in project hazelcast by hazelcast.
the class DynamicMetricsCollectionTest method testDirectLongProveLevelFilters.
@Test
public void testDirectLongProveLevelFilters() {
MetricsCollector collectorMock = mock(MetricsCollector.class);
MetricsRegistry metricsRegistry = new MetricsRegistryImpl(Logger.getLogger(MetricsRegistryImpl.class), MANDATORY);
metricsRegistry.registerDynamicMetricsProvider((descriptor, context) -> context.collect(descriptor.withPrefix("test"), "someMetric", INFO, BYTES, 42));
metricsRegistry.collect(collectorMock);
MetricDescriptor expectedDescriptor = metricsRegistry.newMetricDescriptor().withPrefix("test").withUnit(BYTES).withMetric("someMetric");
verify(collectorMock, never()).collectLong(expectedDescriptor, 42);
}
use of com.hazelcast.internal.metrics.collectors.MetricsCollector in project hazelcast by hazelcast.
the class DynamicMetricsCollectionTest method testDirectDoubleProveLevelFilters.
@Test
public void testDirectDoubleProveLevelFilters() {
MetricsCollector collectorMock = mock(MetricsCollector.class);
MetricsRegistry metricsRegistry = new MetricsRegistryImpl(Logger.getLogger(MetricsRegistryImpl.class), MANDATORY);
metricsRegistry.registerDynamicMetricsProvider((descriptor, context) -> context.collect(descriptor.withPrefix("test"), "someMetric", INFO, BYTES, 42.42D));
metricsRegistry.collect(collectorMock);
MetricDescriptor expectedDescriptor = metricsRegistry.newMetricDescriptor().withPrefix("test").withUnit(BYTES).withMetric("someMetric");
verify(collectorMock, never()).collectDouble(expectedDescriptor, 42.42D);
}
use of com.hazelcast.internal.metrics.collectors.MetricsCollector in project hazelcast by hazelcast.
the class DynamicMetricsCollectionTest method testDynamicProviderExceptionsAreNotPropagated.
@RequireAssertEnabled
@Test
public void testDynamicProviderExceptionsAreNotPropagated() {
MetricsCollector collectorMock = mock(MetricsCollector.class);
MetricsRegistry metricsRegistry = new MetricsRegistryImpl(Logger.getLogger(MetricsRegistryImpl.class), MANDATORY);
metricsRegistry.registerDynamicMetricsProvider((taggerSupplier, context) -> {
throw new RuntimeException("Intentionally failing metrics collection");
});
// we just expect there is no exception apart from AssertionError,
// which is for testing only
Assert.assertThrows(AssertionError.class, () -> metricsRegistry.collect(collectorMock));
}
Aggregations