Search in sources :

Example 56 with MetricDescriptor

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();
}
Also used : MetricConsumer(com.hazelcast.internal.metrics.MetricConsumer) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 57 with MetricDescriptor

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);
    }
}
Also used : MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor)

Example 58 with MetricDescriptor

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));
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor)

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