Search in sources :

Example 6 with MonitoringData

use of fish.payara.monitoring.collect.MonitoringData in project Payara by payara.

the class HoggingThreadsHealthCheck method collect.

@Override
@MonitoringData(ns = "health", intervalSeconds = 4)
public void collect(MonitoringDataCollector collector) {
    if (options == null || !options.isEnabled() || !supported) {
        return;
    }
    AtomicInteger hoggingThreadCount = new AtomicInteger(0);
    AtomicLong hoggingThreadMaxDuration = new AtomicLong(0L);
    acceptHoggingThreads(colletionRecordsByThreadId, (percentage, threshold, totalTimeHogging, initialMethod, info) -> {
        String thread = info.getThreadName();
        if (thread == null || thread.isEmpty()) {
            thread = String.valueOf(info.getThreadId());
        }
        // 
        collector.annotate(// 
        "HoggingThreadDuration", // 
        totalTimeHogging, // 
        true, // 
        "Thread", // 
        thread, // 
        "Usage%", // 
        String.valueOf(percentage), // 
        "Threshold%", // 
        String.valueOf(threshold), // 
        "Method", // 
        initialMethod, "Exited", String.valueOf(!initialMethod.equals(getMethod(info))));
        hoggingThreadCount.incrementAndGet();
        hoggingThreadMaxDuration.updateAndGet(value -> Math.max(value, totalTimeHogging));
    });
    collector.collect("HoggingThreadCount", hoggingThreadCount).collect("HoggingThreadDuration", hoggingThreadMaxDuration);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MonitoringData(fish.payara.monitoring.collect.MonitoringData)

Aggregations

MonitoringData (fish.payara.monitoring.collect.MonitoringData)6 MonitoringDataCollector (fish.payara.monitoring.collect.MonitoringDataCollector)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 RequestTrace (fish.payara.notification.requesttracing.RequestTrace)1 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)1 Queue (java.util.Queue)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1