Search in sources :

Example 6 with MetricDescriptor

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

the class ProviderHelper method provide.

public static void provide(MetricDescriptor descriptor, MetricsCollectionContext context, String prefix, Map<String, ? extends LocalInstanceStats> stats) {
    if (stats == null) {
        return;
    }
    for (Map.Entry<String, ? extends LocalInstanceStats> entry : stats.entrySet()) {
        String name = entry.getKey();
        LocalInstanceStats localStats = entry.getValue();
        MetricDescriptor dsDescriptor = descriptor.copy().withPrefix(prefix).withDiscriminator(GENERAL_DISCRIMINATOR_NAME, name);
        context.collect(dsDescriptor, localStats);
    }
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) Map(java.util.Map) LocalInstanceStats(com.hazelcast.instance.LocalInstanceStats)

Example 7 with MetricDescriptor

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

the class EventServiceImpl method getSegment.

/**
 * Returns the {@link EventServiceSegment} for the {@code service}. If the segment is {@code null} and
 * {@code forceCreate} is {@code true}, the segment is created and registered with the {@link MetricsRegistry}.
 *
 * @param service     the service of the segment
 * @param forceCreate whether the segment should be created in case there is no segment
 * @return the segment for the service or null if there is no segment and {@code forceCreate} is {@code false}
 */
public EventServiceSegment getSegment(@Nonnull String service, boolean forceCreate) {
    EventServiceSegment segment = segments.get(service);
    if (segment == null && forceCreate) {
        // we can't make use of the ConcurrentUtil; we need to register the segment to the metricsRegistry in case of creation
        EventServiceSegment newSegment = new EventServiceSegment(service, nodeEngine.getService(service));
        EventServiceSegment existingSegment = segments.putIfAbsent(service, newSegment);
        if (existingSegment == null) {
            segment = newSegment;
            MetricsRegistry metricsRegistry = nodeEngine.getMetricsRegistry();
            MetricDescriptor descriptor = metricsRegistry.newMetricDescriptor().withPrefix(EVENT_PREFIX).withDiscriminator(EVENT_DISCRIMINATOR_SERVICE, service);
            metricsRegistry.registerStaticMetrics(descriptor, newSegment);
        } else {
            segment = existingSegment;
        }
    }
    return segment;
}
Also used : MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor)

Example 8 with MetricDescriptor

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

the class MetricsContext method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor tagger, MetricsCollectionContext context) {
    if (metrics != null) {
        MetricDescriptor withUserTag = addUserTag(tagger);
        metrics.forEach((name, metric) -> context.collect(withUserTag, name, ProbeLevel.INFO, toProbeUnit(metric.unit()), metric.get()));
    }
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor)

Example 9 with MetricDescriptor

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

the class MapService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    Map<String, LocalMapStats> stats = getStats();
    if (stats == null) {
        return;
    }
    for (Map.Entry<String, LocalMapStats> entry : stats.entrySet()) {
        String mapName = entry.getKey();
        LocalMapStats localInstanceStats = entry.getValue();
        // map
        MetricDescriptor dsDescriptor = descriptor.copy().withPrefix(MAP_PREFIX).withDiscriminator(MAP_DISCRIMINATOR_NAME, mapName);
        context.collect(dsDescriptor, localInstanceStats);
        // index
        Map<String, LocalIndexStats> indexStats = localInstanceStats.getIndexStats();
        for (Map.Entry<String, LocalIndexStats> indexEntry : indexStats.entrySet()) {
            MetricDescriptor indexDescriptor = descriptor.copy().withPrefix(MAP_PREFIX_INDEX).withDiscriminator(MAP_DISCRIMINATOR_NAME, mapName).withTag(MAP_TAG_INDEX, indexEntry.getKey());
            context.collect(indexDescriptor, indexEntry.getValue());
        }
        // near cache
        NearCacheStats nearCacheStats = localInstanceStats.getNearCacheStats();
        if (nearCacheStats != null) {
            MetricDescriptor nearCacheDescriptor = descriptor.copy().withPrefix(MAP_PREFIX_NEARCACHE).withDiscriminator(MAP_DISCRIMINATOR_NAME, mapName);
            context.collect(nearCacheDescriptor, nearCacheStats);
        }
    }
    // stats of offloaded-entry-processor's executor
    ExecutorStats executorStats = mapServiceContext.getOffloadedEntryProcessorExecutorStats();
    executorStats.getStatsMap().forEach((name, offloadedExecutorStats) -> {
        MetricDescriptor nearCacheDescriptor = descriptor.copy().withPrefix(MAP_PREFIX_ENTRY_PROCESSOR_OFFLOADABLE_EXECUTOR).withDiscriminator(MAP_DISCRIMINATOR_NAME, name);
        context.collect(nearCacheDescriptor, offloadedExecutorStats);
    });
}
Also used : LocalMapStats(com.hazelcast.map.LocalMapStats) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) NearCacheStats(com.hazelcast.nearcache.NearCacheStats) Map(java.util.Map) LocalIndexStats(com.hazelcast.query.LocalIndexStats)

Example 10 with MetricDescriptor

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

the class NearCacheMetricsProvider method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    descriptor.withPrefix(NEARCACHE_PREFIX);
    ClientContext clientContext = proxyManager.getContext();
    if (clientContext == null) {
        return;
    }
    clientContext.getNearCacheManagers().values().stream().flatMap(nearCacheManager -> nearCacheManager.listAllNearCaches().stream()).forEach(nearCache -> {
        String nearCacheName = nearCache.getName();
        NearCacheStatsImpl nearCacheStats = (NearCacheStatsImpl) nearCache.getNearCacheStats();
        context.collect(descriptor.copy().withDiscriminator(NEARCACHE_DISCRIMINATOR_NAME, nearCacheName), nearCacheStats);
    });
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ClientContext(com.hazelcast.client.impl.spi.ClientContext) NearCacheStatsImpl(com.hazelcast.internal.monitor.impl.NearCacheStatsImpl) DynamicMetricsProvider(com.hazelcast.internal.metrics.DynamicMetricsProvider) MetricsCollectionContext(com.hazelcast.internal.metrics.MetricsCollectionContext) ProxyManager(com.hazelcast.client.impl.spi.ProxyManager) NEARCACHE_DISCRIMINATOR_NAME(com.hazelcast.internal.metrics.MetricDescriptorConstants.NEARCACHE_DISCRIMINATOR_NAME) NEARCACHE_PREFIX(com.hazelcast.internal.metrics.MetricDescriptorConstants.NEARCACHE_PREFIX) NearCacheStatsImpl(com.hazelcast.internal.monitor.impl.NearCacheStatsImpl) ClientContext(com.hazelcast.client.impl.spi.ClientContext)

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