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);
}
}
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;
}
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()));
}
}
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);
});
}
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);
});
}
Aggregations