Search in sources :

Example 36 with MetricDescriptor

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

the class AtomicRefService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    MetricDescriptor root = descriptor.withPrefix("cp.atomicref");
    for (AtomicRef value : atomicValues.values()) {
        CPGroupId groupId = value.groupId();
        MetricDescriptor desc = root.copy().withDiscriminator("id", value.name() + "@" + groupId.getName()).withTag(CP_TAG_NAME, value.name()).withTag("group", groupId.getName()).withMetric("dummy");
        context.collect(desc, 0);
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor)

Example 37 with MetricDescriptor

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

the class SemaphoreService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    MetricDescriptor root = descriptor.withPrefix("cp.semaphore");
    for (CPGroupId groupId : getGroupIdSet()) {
        SemaphoreRegistry registry = getRegistryOrNull(groupId);
        for (Semaphore sema : registry.getAllSemaphores()) {
            MetricDescriptor desc = root.copy().withDiscriminator("id", sema.getName() + "@" + groupId.getName()).withTag(CP_TAG_NAME, sema.getName()).withTag("group", groupId.getName());
            context.collect(desc.copy().withMetric("initialized"), sema.isInitialized() ? 1 : 0);
            context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("available"), sema.getAvailable());
        }
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ISemaphore(com.hazelcast.cp.ISemaphore)

Example 38 with MetricDescriptor

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

the class FieldProbe method register.

void register(MetricsRegistryImpl metricsRegistry, Object source, String namePrefix) {
    MetricDescriptor descriptor = metricsRegistry.newMetricDescriptor().withPrefix(namePrefix).withMetric(getProbeName());
    metricsRegistry.registerInternal(source, descriptor, probe.level(), this);
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor)

Example 39 with MetricDescriptor

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

the class JmxPublisher method publishNumber.

private void publishNumber(MetricDescriptor originalDescriptor, Number value, MetricsMBean.Type type) {
    if (originalDescriptor.isTargetExcluded(JMX)) {
        return;
    }
    final MetricData metricData;
    if (!metricNameToMetricData.containsKey(originalDescriptor)) {
        // we need to take a copy of originalDescriptor here to ensure
        // we map with an instance that doesn't get recycled or mutated
        MetricDescriptor descriptor = copy(originalDescriptor);
        metricData = metricNameToMetricData.computeIfAbsent(descriptor, createMetricDataFunction);
    } else {
        metricData = metricNameToMetricData.get(originalDescriptor);
    }
    assertDoubleRendering(originalDescriptor, metricData, value);
    metricData.wasPresent = true;
    MetricsMBean mBean = mBeans.computeIfAbsent(metricData.objectName, createMBeanFunction);
    if (isShutdown) {
        unregisterMBeanIgnoreError(metricData.objectName);
    }
    mBean.setMetricValue(metricData.metric, metricData.unit, value, type);
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor)

Example 40 with MetricDescriptor

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

the class FileMetricSet method register.

/**
 * Registers all the metrics in this metric pack.
 *
 * @param metricsRegistry the MetricsRegistry upon which the metrics are registered.
 */
public static void register(MetricsRegistry metricsRegistry) {
    checkNotNull(metricsRegistry, "metricsRegistry");
    File file = new File(System.getProperty("user.home"));
    MetricDescriptor descriptor = metricsRegistry.newMetricDescriptor().withPrefix(FILE_PREFIX).withDiscriminator(FILE_DISCRIMINATOR_DIR, FILE_DISCRIMINATOR_VALUE_DIR);
    metricsRegistry.registerStaticProbe(file, descriptor, FILE_METRIC_FREESPACE, MANDATORY, BYTES, File::getFreeSpace);
    metricsRegistry.registerStaticProbe(file, descriptor, FILE_METRIC_TOTALSPACE, MANDATORY, BYTES, File::getTotalSpace);
    metricsRegistry.registerStaticProbe(file, descriptor, FILE_METRIC_USABLESPACE, MANDATORY, BYTES, File::getUsableSpace);
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) File(java.io.File)

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