Search in sources :

Example 1 with MonitoringData

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

the class SQLTraceStoreImpl method collect.

@Override
@MonitoringData(ns = "sql")
public void collect(MonitoringDataCollector collector) {
    long now = System.currentTimeMillis();
    for (Entry<String, Queue<SQLTraceEntry>> poolEntry : uncollectedTracesByPoolName.entrySet()) {
        MonitoringDataCollector poolCollector = collector.group(poolEntry.getKey());
        int count = 0;
        long maxExecutionTime = 0L;
        long sumExecutionTime = 0L;
        Queue<SQLTraceEntry> entries = poolEntry.getValue();
        SQLTraceEntry entry = entries.poll();
        while (entry != null) {
            if (now - entry.trace.getTimeStamp() < 5000) {
                // only add trace in case it was from last 5 seconds
                count++;
                long executionTime = entry.trace.getExecutionTime();
                maxExecutionTime = Math.max(maxExecutionTime, executionTime);
                sumExecutionTime += executionTime;
                if (executionTime > entry.thresholdMillis) {
                    // 
                    poolCollector.annotate(// 
                    "MaxExecutionTime", // 
                    executionTime, // 
                    "Threshold", // 
                    "" + entry.thresholdMillis, // 
                    "Timestamp", // 
                    "" + entry.trace.getTimeStamp(), "SQL", entry.sql);
                }
            }
            entry = entries.poll();
        }
        poolCollector.collect("MaxExecutionTime", maxExecutionTime).collect("AvgExecutionTime", count == 0L ? 0L : sumExecutionTime / count);
    }
}
Also used : MonitoringDataCollector(fish.payara.monitoring.collect.MonitoringDataCollector) Queue(java.util.Queue) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) MonitoringData(fish.payara.monitoring.collect.MonitoringData)

Example 2 with MonitoringData

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

the class RequestTracingService method collect.

@Override
@MonitoringData(ns = "trace")
public void collect(MonitoringDataCollector collector) {
    for (String group : activeCollectionGroups.keySet()) {
        collector.group(group).collect(DURATION, 0);
        activeCollectionGroups.compute(group, (key, value) -> value <= 1 ? null : value - 1);
    }
    long thresholdInMillis = getConfigurationThresholdInMillis();
    RequestTrace trace = uncollectedTraces.poll();
    while (trace != null) {
        String group = collectTrace(collector, trace, thresholdInMillis);
        if (group != null) {
            activeCollectionGroups.compute(group, (key, value) -> 35);
        }
        trace = uncollectedTraces.poll();
    }
}
Also used : RequestTrace(fish.payara.notification.requesttracing.RequestTrace) MonitoringData(fish.payara.monitoring.collect.MonitoringData)

Example 3 with MonitoringData

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

the class FaultToleranceServiceImpl method collect.

@Override
@MonitoringData(ns = "ft")
public void collect(MonitoringDataCollector collector) {
    for (Entry<MethodKey, FaultToleranceMethodContextImpl> methodEntry : contextByMethod.entrySet()) {
        MonitoringDataCollector methodCollector = collector.group(methodEntry.getKey().getMethodId()).tag("app", methodEntry.getValue().getAppName());
        FaultToleranceMethodContext context = methodEntry.getValue();
        BlockingQueue<Thread> concurrentExecutions = context.getConcurrentExecutions();
        if (concurrentExecutions != null) {
            collectBulkheadSemaphores(methodCollector, concurrentExecutions);
            collectBulkheadSemaphores(methodCollector, concurrentExecutions, context.getQueuingOrRunningPopulation());
        }
        collectCircuitBreakerState(methodCollector, context.getState());
    }
}
Also used : MonitoringDataCollector(fish.payara.monitoring.collect.MonitoringDataCollector) MonitoringData(fish.payara.monitoring.collect.MonitoringData)

Example 4 with MonitoringData

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

the class GarbageCollectorHealthCheck method collect.

@Override
@MonitoringData(ns = "health", intervalSeconds = 4)
public void collect(MonitoringDataCollector collector) {
    if (options == null || !options.isEnabled()) {
        return;
    }
    for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans()) {
        GcUsage usage = collect.computeIfAbsent(gcBean.getName(), key -> new GcUsage());
        // update
        double percentage = usage.percentage(gcBean);
        if (isYoungGenerationGC(gcBean)) {
            collectGcUage(collector, "Young", percentage, usage.getNumberOfGcs(), usage.getTimeSpendDoingGc());
        } else if (isOldGenerationGC(gcBean)) {
            collectGcUage(collector, "Old", percentage, usage.getNumberOfGcs(), usage.getTimeSpendDoingGc());
        }
    }
    long timeSpendDoingGc = 0;
    long timePassed = 0;
    long numberOfGcs = 0;
    for (GcUsage u : collect.values()) {
        timePassed = Math.max(timePassed, u.getTimePassed());
        timeSpendDoingGc += u.getTimeSpendDoingGc();
        numberOfGcs += u.getNumberOfGcs();
    }
    double usage = timePassed == 0 ? 0d : 100d * timeSpendDoingGc / timePassed;
    collectGcUage(collector, "Total", usage, numberOfGcs, timeSpendDoingGc);
}
Also used : GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) MonitoringData(fish.payara.monitoring.collect.MonitoringData)

Example 5 with MonitoringData

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

the class StuckThreadsHealthCheck method collect.

@Override
@MonitoringData(ns = "health", intervalSeconds = 4)
public void collect(MonitoringDataCollector collector) {
    if (options == null || !options.isEnabled()) {
        return;
    }
    AtomicInteger count = new AtomicInteger(0);
    AtomicLong maxDuration = new AtomicLong(0L);
    acceptStuckThreads((workStartedTime, timeWorkingInMillis, thresholdInMillis, info) -> {
        String thread = info.getThreadName();
        if (thread == null || thread.isEmpty()) {
            thread = String.valueOf(info.getThreadId());
        }
        // 
        collector.annotate(// 
        "StuckThreadDuration", // 
        timeWorkingInMillis, // 
        true, // OBS! must be the first attribute as it is the key.
        "Thread", // OBS! must be the first attribute as it is the key.
        thread, // 
        "Started", // 
        String.valueOf(workStartedTime), // 
        "Threshold", // 
        String.valueOf(thresholdInMillis), // 
        "Locked", // 
        Boolean.toString(info.getLockInfo() != null), // 
        "Suspended", // 
        String.valueOf(info.isSuspended()), "State", composeStateText(info));
        count.incrementAndGet();
        maxDuration.updateAndGet(value -> Math.max(value, timeWorkingInMillis));
    });
    collector.collect("StuckThreadDuration", maxDuration);
    collector.collect("StuckThreadCount", count);
}
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