use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class MetricsCompressorTest method testTwoMetrics_withDelta.
@Test
public void testTwoMetrics_withDelta() {
DefaultMetricDescriptorSupplier supplier = new DefaultMetricDescriptorSupplier();
MetricsCompressor compressor = new MetricsCompressor();
MetricDescriptor metric1 = supplier.get().withPrefix("prefix").withMetric("metricName").withDiscriminator("ds", "dsName1").withUnit(COUNT).withTag("tag0", "tag0Value");
MetricDescriptor metric2 = metric1.copy().withMetric("metricName2");
compressor.addLong(metric1, 42L);
compressor.addLong(metric2, 43L);
byte[] blob = compressor.getBlobAndReset();
MetricConsumer metricConsumerMock = mock(MetricConsumer.class);
MetricsCompressor.extractMetrics(blob, metricConsumerMock, supplierSpy);
verify(metricConsumerMock).consumeLong(metric1, 42L);
verify(metricConsumerMock).consumeLong(metric2, 43L);
verifyNoMoreInteractions(metricConsumerMock);
verify(supplierSpy, times(2)).get();
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class MetricsPropertiesTest method verifyDataStructureMetricPresent.
private void verifyDataStructureMetricPresent(HazelcastInstance instance, boolean shouldContain) {
CapturingCollector collector = new CapturingCollector();
instance.getMap("testMap").put("42", "42");
MetricsRegistry metricsRegistry = getNodeEngineImpl(instance).getMetricsRegistry();
metricsRegistry.collect(collector);
MetricDescriptor descriptor = DEFAULT_DESCRIPTOR_SUPPLIER.get().withPrefix(MAP_PREFIX).withDiscriminator(MAP_DISCRIMINATOR_NAME, "testMap").withMetric("putCount").withUnit(COUNT);
if (shouldContain) {
assertContains(collector.captures().keySet(), descriptor);
} else {
assertNotContains(collector.captures().keySet(), descriptor);
}
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class MetricsTargetExclusionTest method verifyCollected.
private void verifyCollected(String prefix, String metricName, Collection<MetricTarget> excludedTargets) {
MetricDescriptor descriptor = DEFAULT_DESCRIPTOR_SUPPLIER.get().withPrefix(prefix).withMetric(metricName).withUnit(COUNT).withExcludedTargets(excludedTargets);
assertTrue(collector.isCaptured(descriptor));
}
Aggregations