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);
}
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)))));
}
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"));
}
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());
}
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)))));
}
Aggregations