use of fish.payara.monitoring.collect.MonitoringDataCollector in project Payara by payara.
the class GrizzlyService method collect.
@Override
public void collect(MonitoringDataCollector collector) {
if (!"true".equals(monitoringService.getMonitoringEnabled()) || !"HIGH".equals(monitoringService.getModuleMonitoringLevels().getHttpService())) {
return;
}
MonitoringDataCollector httpCollector = collector.in("http");
httpCollector.prefix("ThreadPool").collectObject(monitoring.getThreadPoolStatsProvider(NETWORK_CONFIG_PREFIX), MonitoringDataCollection::collectObject);
httpCollector.prefix("ConnectionQueue").collectObject(monitoring.getConnectionQueueStatsProvider(NETWORK_CONFIG_PREFIX), MonitoringDataCollection::collectObject);
httpCollector.prefix("FileCache").collectObject(monitoring.getFileCacheStatsProvider(NETWORK_CONFIG_PREFIX), MonitoringDataCollection::collectObject);
}
use of fish.payara.monitoring.collect.MonitoringDataCollector 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);
}
}
use of fish.payara.monitoring.collect.MonitoringDataCollector in project Payara by payara.
the class MetricsServiceImpl method processMetadataToAnnotations.
private static void processMetadataToAnnotations(MetricsContextImpl context, MonitoringDataCollector collector) {
RegisteredMetric metric = context.pollNewlyRegistered();
while (metric != null) {
MetricID metricID = metric.id;
Type scope = metric.scope;
MetricRegistry registry = context.getRegistry(scope);
MonitoringDataCollector metricCollector = tagCollector(context.getName(), metricID, collector);
Metadata metadata = registry.getMetadata(metricID.getName());
String suffix = "Count";
String property = "Count";
boolean isGauge = metadata.getTypeRaw() == MetricType.GAUGE;
if (isGauge) {
suffix = getMetricUnitSuffix(metadata.unit());
property = "Value";
}
// Note that by convention an annotation with value 0 done before the series collected any value is considered permanent
metricCollector.annotate(toName(metricID, suffix), 0, false, metadataToAnnotations(context.getName(), scope, metadata, property));
metric = context.pollNewlyRegistered();
}
}
use of fish.payara.monitoring.collect.MonitoringDataCollector in project Payara by payara.
the class HealthCheckService method collectChecks.
private Map<String, List<HealthCheckResponse>> collectChecks(MonitoringDataCollector collector, Map<String, Set<HealthCheck>> checks, Map<String, Set<String>> collected) {
Map<String, List<HealthCheckResponse>> statusByApp = new HashMap<>();
for (Entry<String, Set<HealthCheck>> entry : checks.entrySet()) {
String appName = entry.getKey();
MonitoringDataCollector appCollector = collector.group(appName);
for (HealthCheck check : entry.getValue()) {
HealthCheckResponse response = performHealthCheckInApplicationContext(appName, check);
String metric = response.getName();
Set<String> appCollected = collected.get(appName);
// prevent adding same check more then once, unfortunately we have to run it to find that out
if (appCollected == null || !appCollected.contains(metric)) {
statusByApp.computeIfAbsent(appName, key -> new ArrayList<>()).add(response);
collectUpDown(appCollector, response);
if (response.getStatus() == Status.DOWN && response.getData().isPresent()) {
appCollector.annotate(metric, 0L, createAnnotation(response.getData().get()));
}
collected.computeIfAbsent(appName, key -> new HashSet<>()).add(metric);
}
}
}
return statusByApp;
}
use of fish.payara.monitoring.collect.MonitoringDataCollector in project Payara by payara.
the class MetricsServiceImpl method collect.
@Override
public void collect(MonitoringDataCollector rootCollector) {
if (!isEnabled())
return;
MonitoringDataCollector metricsCollector = rootCollector.in("metric");
for (MetricsContextImpl context : contextByName.values()) {
processMetadataToAnnotations(context, metricsCollector);
String contextName = context.getName();
collectRegistry(contextName, context.getBaseRegistry(), metricsCollector);
collectRegistry(contextName, context.getVendorRegistry(), metricsCollector);
if (!context.isServerContext()) {
collectRegistry(contextName, context.getApplicationRegistry(), metricsCollector);
}
}
}
Aggregations