Search in sources :

Example 16 with Metrics

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;
}
Also used : PoolArenaMetric(io.netty.buffer.PoolArenaMetric) ManagedLedgerFactoryMXBean(org.apache.bookkeeper.mledger.ManagedLedgerFactoryMXBean) Metrics(org.apache.pulsar.common.stats.Metrics) PoolChunkListMetric(io.netty.buffer.PoolChunkListMetric) PoolChunkMetric(io.netty.buffer.PoolChunkMetric) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator)

Example 17 with 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;
}
Also used : ManagedLedgerImpl(org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl) Metrics(org.apache.pulsar.common.stats.Metrics)

Example 18 with Metrics

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;
}
Also used : Metrics(org.apache.pulsar.common.stats.Metrics)

Aggregations

Metrics (org.apache.pulsar.common.stats.Metrics)18 Test (org.testng.annotations.Test)4 PoolArenaMetric (io.netty.buffer.PoolArenaMetric)3 PoolChunkListMetric (io.netty.buffer.PoolChunkListMetric)3 PoolChunkMetric (io.netty.buffer.PoolChunkMetric)3 ManagedLedgerImpl (org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl)3 HashMap (java.util.HashMap)2 BrokerService (org.apache.pulsar.broker.service.BrokerService)2 AtomicDouble (com.google.common.util.concurrent.AtomicDouble)1 Gson (com.google.gson.Gson)1 TypeToken (com.google.gson.reflect.TypeToken)1 ByteBuf (io.netty.buffer.ByteBuf)1 PooledByteBufAllocator (io.netty.buffer.PooledByteBufAllocator)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1