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