use of org.apache.pulsar.common.stats.Metrics in project incubator-pulsar by apache.
the class ManagedLedgerCacheMetrics method generate.
@Override
public synchronized List<Metrics> generate() {
// get the ML cache stats bean
ManagedLedgerFactoryMXBean mlCacheStats = getManagedLedgerCacheStats();
Metrics m = createMetrics();
m.put("brk_ml_count", mlCacheStats.getNumberOfManagedLedgers());
m.put("brk_ml_cache_used_size", mlCacheStats.getCacheUsedSize());
m.put("brk_ml_cache_evictions", mlCacheStats.getNumberOfCacheEvictions());
m.put("brk_ml_cache_hits_rate", mlCacheStats.getCacheHitsRate());
m.put("brk_ml_cache_misses_rate", mlCacheStats.getCacheMissesRate());
m.put("brk_ml_cache_hits_throughput", mlCacheStats.getCacheHitsThroughput());
m.put("brk_ml_cache_misses_throughput", mlCacheStats.getCacheMissesThroughput());
PooledByteBufAllocator allocator = EntryCacheImpl.ALLOCATOR;
long activeAllocations = 0;
long activeAllocationsTiny = 0;
long activeAllocationsSmall = 0;
long activeAllocationsNormal = 0;
long activeAllocationsHuge = 0;
long totalAllocated = 0;
long totalUsed = 0;
for (PoolArenaMetric arena : allocator.metric().directArenas()) {
activeAllocations += arena.numActiveAllocations();
activeAllocationsTiny += arena.numActiveTinyAllocations();
activeAllocationsSmall += arena.numActiveSmallAllocations();
activeAllocationsNormal += arena.numActiveNormalAllocations();
activeAllocationsHuge += arena.numActiveHugeAllocations();
for (PoolChunkListMetric list : arena.chunkLists()) {
for (PoolChunkMetric chunk : list) {
int size = chunk.chunkSize();
int used = size - chunk.freeBytes();
totalAllocated += size;
totalUsed += used;
}
}
}
m.put("brk_ml_cache_pool_allocated", totalAllocated);
m.put("brk_ml_cache_pool_used", totalUsed);
m.put("brk_ml_cache_pool_active_allocations", activeAllocations);
m.put("brk_ml_cache_pool_active_allocations_tiny", activeAllocationsTiny);
m.put("brk_ml_cache_pool_active_allocations_small", activeAllocationsSmall);
m.put("brk_ml_cache_pool_active_allocations_normal", activeAllocationsNormal);
m.put("brk_ml_cache_pool_active_allocations_huge", activeAllocationsHuge);
metrics.clear();
metrics.add(m);
return metrics;
}
use of org.apache.pulsar.common.stats.Metrics in project incubator-pulsar by apache.
the class ManagedLedgerMetrics method groupLedgersByDimension.
/**
* Build a map of dimensions key to list of topic stats (not thread-safe)
* <p>
*
* @return
*/
private Map<Metrics, List<ManagedLedgerImpl>> groupLedgersByDimension() {
ledgersByDimensionMap.clear();
for (Entry<String, ManagedLedgerImpl> e : getManagedLedgers().entrySet()) {
String ledgerName = e.getKey();
ManagedLedgerImpl ledger = e.getValue();
// we want to aggregate by NS dimension
String namespace = parseNamespaceFromLedgerName(ledgerName);
Metrics metrics = createMetricsByDimension(namespace);
populateDimensionMap(ledgersByDimensionMap, metrics, ledger);
}
return ledgersByDimensionMap;
}
use of org.apache.pulsar.common.stats.Metrics in project incubator-pulsar by apache.
the class BrokerOperabilityMetrics method getDimensionMetrics.
Metrics getDimensionMetrics(String metricsName, String dimensionName, DimensionStats stats) {
Map<String, String> dimensionMap = Maps.newHashMap();
dimensionMap.put("broker", brokerName);
dimensionMap.put("cluster", localCluster);
dimensionMap.put("metric", metricsName);
Metrics dMetrics = Metrics.create(dimensionMap);
dMetrics.put("brk_" + dimensionName + "_time_mean_ms", stats.getMeanDimension());
dMetrics.put("brk_" + dimensionName + "_time_median_ms", stats.getMedianDimension());
dMetrics.put("brk_" + dimensionName + "_time_75percentile_ms", stats.getDimension75());
dMetrics.put("brk_" + dimensionName + "_time_95percentile_ms", stats.getDimension95());
dMetrics.put("brk_" + dimensionName + "_time_99_percentile_ms", stats.getDimension99());
dMetrics.put("brk_" + dimensionName + "_time_99_9_percentile_ms", stats.getDimension999());
dMetrics.put("brk_" + dimensionName + "_time_99_99_percentile_ms", stats.getDimension9999());
dMetrics.put("brk_" + dimensionName + "_rate_s", stats.getDimensionCount());
return dMetrics;
}
Aggregations