Search in sources :

Example 1 with MetricDescriptor

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

the class CountDownLatchService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    MetricDescriptor root = descriptor.withPrefix("cp.countdownlatch");
    for (CPGroupId groupId : getGroupIdSet()) {
        CountDownLatchRegistry registry = getRegistryOrNull(groupId);
        for (CountDownLatch latch : registry.getAllLatches()) {
            MetricDescriptor desc = root.copy().withDiscriminator("id", latch.getName() + "@" + groupId.getName()).withTag(CP_TAG_NAME, latch.getName()).withTag("group", groupId.getName());
            context.collect(desc.copy().withMetric("round"), latch.getRound());
            context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("count"), latch.getCount());
            context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("remaining"), latch.getRemainingCount());
        }
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ICountDownLatch(com.hazelcast.cp.ICountDownLatch)

Example 2 with MetricDescriptor

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

the class LockService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    MetricDescriptor root = descriptor.withPrefix("cp.lock");
    for (CPGroupId groupId : getGroupIdSet()) {
        LockRegistry registry = getRegistryOrNull(groupId);
        for (Lock lock : registry.getAllLocks()) {
            MetricDescriptor desc = root.copy().withDiscriminator("id", lock.getName() + "@" + groupId.getName()).withTag(CP_TAG_NAME, lock.getName()).withTag("group", groupId.getName());
            context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("acquireLimit"), lock.lockCountLimit());
            LockInvocationKey owner = lock.owner();
            int lockCount = lock.lockCount();
            // We may observe a partial update.
            if (owner != null && lockCount > 0) {
                context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("lockCount"), lockCount);
                context.collect(desc.copy().withMetric("ownerSessionId"), owner.sessionId());
                context.collect(desc.copy().withTag("owner", owner.callerAddress().toString()).withMetric("owner"), 0);
            } else {
                context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("lockCount"), 0);
            }
        }
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) FencedLock(com.hazelcast.cp.lock.FencedLock)

Example 3 with MetricDescriptor

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

the class RaftSessionService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    MetricDescriptor root = descriptor.withPrefix("cp.session");
    for (RaftSessionRegistry registry : registries.values()) {
        CPGroupId groupId = registry.groupId();
        for (CPSession session : registry.getSessions()) {
            MetricDescriptor desc = root.copy().withDiscriminator("id", session.id() + "@" + groupId.getName()).withTag("sessionId", String.valueOf(session.id())).withTag("group", groupId.getName());
            context.collect(desc.copy().withTag("endpoint", session.endpoint().toString()).withMetric("endpoint"), 0);
            context.collect(desc.copy().withTag("endpointType", session.endpointType().toString()).withMetric("endpointType"), 0);
            context.collect(desc.copy().withMetric("version"), session.version());
            context.collect(desc.copy().withUnit(ProbeUnit.MS).withMetric("creationTime"), session.creationTime());
            context.collect(desc.copy().withUnit(ProbeUnit.MS).withMetric("expirationTime"), session.expirationTime());
        }
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) CPSession(com.hazelcast.cp.session.CPSession)

Example 4 with MetricDescriptor

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

the class MethodProbe 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 5 with MetricDescriptor

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

the class MetricsCompressor method writeDescriptor.

@SuppressWarnings({ "checkstyle:CyclomaticComplexity", "checkstyle:NPathComplexity" })
private void writeDescriptor(MetricDescriptor originalDescriptor) throws IOException, LongWordException {
    MetricDescriptor descriptor = prepareDescriptor(originalDescriptor);
    int mask = calculateDescriptorMask(descriptor);
    tmpDos.writeByte(mask);
    if ((mask & MASK_PREFIX) == 0) {
        tmpDos.writeInt(getDictionaryId(descriptor.prefix()));
    }
    if ((mask & MASK_METRIC) == 0) {
        tmpDos.writeInt(getDictionaryId(descriptor.metric()));
    }
    if ((mask & MASK_DISCRIMINATOR) == 0) {
        tmpDos.writeInt(getDictionaryId(descriptor.discriminator()));
    }
    if ((mask & MASK_DISCRIMINATOR_VALUE) == 0) {
        tmpDos.writeInt(getDictionaryId(descriptor.discriminatorValue()));
    }
    if ((mask & MASK_UNIT) == 0) {
        ProbeUnit unit = descriptor.unit();
        if (unit != null) {
            tmpDos.writeByte(unit.ordinal());
        } else {
            tmpDos.writeByte(NULL_UNIT);
        }
    }
    if ((mask & MASK_EXCLUDED_TARGETS) == 0) {
        tmpDos.writeByte(MetricTarget.bitset(descriptor.excludedTargets()));
    }
    if ((mask & MASK_TAG_COUNT) == 0) {
        tmpDos.writeByte(descriptor.tagCount());
    }
    // further compression is possible by writing only the different tags
    for (int i = 0; i < descriptor.tagCount(); i++) {
        String tag = descriptor.tag(i);
        String tagValue = descriptor.tagValue(i);
        tmpDos.writeInt(getDictionaryId(tag));
        tmpDos.writeInt(getDictionaryId(tagValue));
    }
    count++;
    lastDescriptor = copyDescriptor(descriptor, lastDescriptor);
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ProbeUnit(com.hazelcast.internal.metrics.ProbeUnit)

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