Search in sources :

Example 31 with MetricDescriptor

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

the class OperationThread method provideStaticMetrics.

@Override
public void provideStaticMetrics(MetricsRegistry registry) {
    MetricDescriptor descriptor = registry.newMetricDescriptor().withPrefix(OPERATION_PREFIX_THREAD).withDiscriminator(OPERATION_DISCRIMINATOR_THREAD, getName());
    registry.registerStaticMetrics(descriptor, this);
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor)

Example 32 with MetricDescriptor

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

the class JobMetricsUtil method addMemberPrefixFn.

public static UnaryOperator<MetricDescriptor> addMemberPrefixFn(@Nonnull Member member) {
    String uuid = member.getUuid().toString();
    String addr = member.getAddress().toString();
    return d -> d.copy().withTag(MetricTags.MEMBER, uuid).withTag(MetricTags.ADDRESS, addr);
}
Also used : Measurement(com.hazelcast.jet.core.metrics.Measurement) JobMetrics(com.hazelcast.jet.core.metrics.JobMetrics) Member(com.hazelcast.cluster.Member) MetricsCompressor(com.hazelcast.internal.metrics.impl.MetricsCompressor) HashMap(java.util.HashMap) UnaryOperator(java.util.function.UnaryOperator) MetricConsumer(com.hazelcast.internal.metrics.MetricConsumer) RawJobMetrics(com.hazelcast.jet.impl.metrics.RawJobMetrics) MetricTags(com.hazelcast.jet.core.metrics.MetricTags) MapUtil(com.hazelcast.internal.util.MapUtil) ArrayList(java.util.ArrayList) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) List(java.util.List) Map(java.util.Map) Util.idFromString(com.hazelcast.jet.Util.idFromString) Nonnull(javax.annotation.Nonnull) Util.idFromString(com.hazelcast.jet.Util.idFromString)

Example 33 with MetricDescriptor

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

the class ProcessorTasklet method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext mContext) {
    descriptor = descriptor.withTag(MetricTags.VERTEX, this.context.vertexName()).withTag(MetricTags.PROCESSOR_TYPE, this.processor.getClass().getSimpleName()).withTag(MetricTags.PROCESSOR, Integer.toString(this.context.globalProcessorIndex()));
    if (isSource) {
        descriptor = descriptor.withTag(MetricTags.SOURCE, "true");
    }
    if (outstreams.length == 0) {
        descriptor = descriptor.withTag(MetricTags.SINK, "true");
    }
    for (int i = 0; i < instreams.size(); i++) {
        MetricDescriptor descWithOrdinal = descriptor.copy().withTag(MetricTags.ORDINAL, String.valueOf(i));
        mContext.collect(descWithOrdinal, RECEIVED_COUNT, ProbeLevel.INFO, ProbeUnit.COUNT, receivedCounts.get(i));
        mContext.collect(descWithOrdinal, RECEIVED_BATCHES, ProbeLevel.INFO, ProbeUnit.COUNT, receivedBatches.get(i));
    }
    for (int i = 0; i < emittedCounts.length() - (this.context.snapshottingEnabled() ? 0 : 1); i++) {
        String ordinal = i == emittedCounts.length() - 1 ? "snapshot" : String.valueOf(i);
        MetricDescriptor descriptorWithOrdinal = descriptor.copy().withTag(MetricTags.ORDINAL, ordinal);
        mContext.collect(descriptorWithOrdinal, EMITTED_COUNT, ProbeLevel.INFO, ProbeUnit.COUNT, emittedCounts.get(i));
    }
    mContext.collect(descriptor, TOP_OBSERVED_WM, ProbeLevel.INFO, ProbeUnit.MS, watermarkCoalescer.topObservedWm());
    mContext.collect(descriptor, COALESCED_WM, ProbeLevel.INFO, ProbeUnit.MS, watermarkCoalescer.coalescedWm());
    mContext.collect(descriptor, LAST_FORWARDED_WM, ProbeLevel.INFO, ProbeUnit.MS, outbox.lastForwardedWm());
    mContext.collect(descriptor, LAST_FORWARDED_WM_LATENCY, ProbeLevel.INFO, ProbeUnit.MS, lastForwardedWmLatency());
    mContext.collect(descriptor, this);
    // collect static metrics from processor
    mContext.collect(descriptor, this.processor);
    // collect dynamic metrics from processor
    if (processor instanceof DynamicMetricsProvider) {
        ((DynamicMetricsProvider) processor).provideDynamicMetrics(descriptor.copy(), mContext);
    }
    if (context instanceof ProcCtx) {
        ((ProcCtx) context).metricsContext().provideDynamicMetrics(descriptor, mContext);
    }
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) DynamicMetricsProvider(com.hazelcast.internal.metrics.DynamicMetricsProvider) ProcCtx(com.hazelcast.jet.impl.execution.init.Contexts.ProcCtx)

Example 34 with MetricDescriptor

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

the class RaftService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    MetricDescriptor rootDescriptor = descriptor.withPrefix(CP_PREFIX_RAFT_GROUP);
    for (Entry<CPGroupId, RaftNodeMetrics> entry : nodeMetrics.entrySet()) {
        CPGroupId groupId = entry.getKey();
        RaftRole role = entry.getValue().role;
        MetricDescriptor groupDescriptor = rootDescriptor.copy().withDiscriminator(CP_DISCRIMINATOR_GROUPID, String.valueOf(groupId.getId())).withTag(CP_TAG_NAME, groupId.getName()).withTag("role", role != null ? role.toString() : "NONE");
        context.collect(groupDescriptor, entry.getValue());
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) RaftRole(com.hazelcast.cp.internal.raft.impl.RaftRole)

Example 35 with MetricDescriptor

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

the class AtomicLongService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    MetricDescriptor root = descriptor.withPrefix("cp.atomiclong");
    for (AtomicLong 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("value");
        context.collect(desc, value.value());
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) IAtomicLong(com.hazelcast.cp.IAtomicLong)

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