Search in sources :

Example 21 with MetricDescriptor

use of com.hazelcast.internal.metrics.MetricDescriptor 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);
}
Also used : MetricsCollector(com.hazelcast.internal.metrics.collectors.MetricsCollector) Logger(com.hazelcast.logging.Logger) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) MetricsCollector(com.hazelcast.internal.metrics.collectors.MetricsCollector) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Mockito.verify(org.mockito.Mockito.verify) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) DEFAULT_DESCRIPTOR_SUPPLIER(com.hazelcast.internal.metrics.impl.DefaultMetricDescriptorSupplier.DEFAULT_DESCRIPTOR_SUPPLIER) ProbeLevel(com.hazelcast.internal.metrics.ProbeLevel) LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 22 with MetricDescriptor

use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.

the class JmxPublisherTest method when_singleMetric.

@Test
public void when_singleMetric() throws Exception {
    MetricDescriptor descriptor = newDescriptor().withMetric("c").withTag("tag1", "a").withTag("tag2", "b");
    jmxPublisher.publishLong(descriptor, 1L);
    helper.assertMBeans(singletonList(metric(domainPrefix + ":type=Metrics,instance=inst1,tag0=\"tag1=a\",tag1=\"tag2=b\"", singletonList(longValue("c", 1L)))));
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 23 with MetricDescriptor

use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.

the class JmxPublisherTest method when_double_rendering_values_are_reported.

@Test
public void when_double_rendering_values_are_reported() {
    MetricDescriptor descriptor1 = newDescriptor().withMetric("c").withTag("tag1", "a").withTag("tag2", "b");
    jmxPublisher.publishLong(descriptor1, 1L);
    MetricDescriptor descriptor2 = newDescriptor().withMetric("c").withTag("tag1", "a").withTag("tag2", "b");
    AssertionError assertionError = assertThrows(AssertionError.class, () -> jmxPublisher.publishLong(descriptor2, 2L));
    assertTrue(assertionError.getMessage().contains("[metric=c,tag1=a,tag2=b,excludedTargets={}]"));
    assertTrue(assertionError.getMessage().contains("Present value: 1, new value: 2"));
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 24 with MetricDescriptor

use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.

the class JmxPublisherTest method when_shutdown_noMBeansLeak.

@Test
public void when_shutdown_noMBeansLeak() throws Exception {
    MetricDescriptor descriptor = newDescriptor().withMetric("c").withTag("tag1", "a").withTag("tag2", "b");
    jmxPublisher.publishLong(descriptor, 1L);
    jmxPublisher.whenComplete();
    helper.assertMBeans(singletonList(metric(domainPrefix + ":type=Metrics,instance=inst1,tag0=\"tag1=a\",tag1=\"tag2=b\"", singletonList(longValue("c", 1L)))));
    jmxPublisher.shutdown();
    helper.assertMBeans(emptyList());
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 25 with MetricDescriptor

use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.

the class JmxPublisherTest method when_singleMetricWithPrefixAndDiscriminator.

@Test
public void when_singleMetricWithPrefixAndDiscriminator() throws Exception {
    MetricDescriptor descriptor = newDescriptor().withPrefix("d").withMetric("c").withDiscriminator("name", "itsName").withTag("tag1", "a").withTag("tag2", "b");
    jmxPublisher.publishLong(descriptor, 1L);
    helper.assertMBeans(singletonList(metric(domainPrefix + ":type=Metrics,instance=inst1,prefix=d,tag0=\"tag1=a\",tag1=\"tag2=b\",tag2=\"name=itsName\"", singletonList(longValue("c", 1L)))));
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)58 QuickTest (com.hazelcast.test.annotation.QuickTest)27 Test (org.junit.Test)27 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)21 MetricConsumer (com.hazelcast.internal.metrics.MetricConsumer)19 CPGroupId (com.hazelcast.cp.CPGroupId)7 MetricsRegistry (com.hazelcast.internal.metrics.MetricsRegistry)6 Map (java.util.Map)4 MetricsCollector (com.hazelcast.internal.metrics.collectors.MetricsCollector)3 InOrder (org.mockito.InOrder)3 ClientStatistics (com.hazelcast.client.impl.statistics.ClientStatistics)2 DynamicMetricsProvider (com.hazelcast.internal.metrics.DynamicMetricsProvider)2 ProbeUnit (com.hazelcast.internal.metrics.ProbeUnit)2 UUID (java.util.UUID)2 Client (com.hazelcast.client.Client)1 ClientEngine (com.hazelcast.client.impl.ClientEngine)1 ClientContext (com.hazelcast.client.impl.spi.ClientContext)1 ProxyManager (com.hazelcast.client.impl.spi.ProxyManager)1 Member (com.hazelcast.cluster.Member)1 IAtomicLong (com.hazelcast.cp.IAtomicLong)1