in src/main/java/org/opensearch/performanceanalyzer/collectors/ClusterApplierServiceStatsCollector.java [84:135]
public void collectMetrics(long startTime) {
if (!controller.isCollectorEnabled(configOverridesWrapper, getCollectorName())) {
return;
}
try {
long mCurrT = System.currentTimeMillis();
if (OpenSearchResources.INSTANCE.getClusterService() == null
|| OpenSearchResources.INSTANCE.getClusterService().getClusterApplierService()
== null) {
return;
}
ClusterApplierServiceStats currentClusterApplierServiceStats = null;
try {
currentClusterApplierServiceStats =
mapper.readValue(
mapper.writeValueAsString(getClusterApplierServiceStats()),
ClusterApplierServiceStats.class);
} catch (InvocationTargetException
| IllegalAccessException
| NoSuchMethodException ex) {
LOG.warn(
"No method found to get cluster state applier thread stats. "
+ "Skipping ClusterApplierServiceStatsCollector");
return;
}
ClusterApplierServiceMetrics clusterApplierServiceMetrics =
new ClusterApplierServiceMetrics(
computeLatency(currentClusterApplierServiceStats),
computeFailure(currentClusterApplierServiceStats));
value.setLength(0);
value.append(PerformanceAnalyzerMetrics.getJsonCurrentMilliSeconds())
.append(PerformanceAnalyzerMetrics.sMetricNewLineDelimitor);
value.append(clusterApplierServiceMetrics.serialize());
saveMetricValues(value.toString(), startTime);
ClusterApplierServiceStatsCollector.prevClusterApplierServiceStats =
currentClusterApplierServiceStats;
PerformanceAnalyzerApp.WRITER_METRICS_AGGREGATOR.updateStat(
WriterMetrics.CLUSTER_APPLIER_SERVICE_STATS_COLLECTOR_EXECUTION_TIME,
"",
System.currentTimeMillis() - mCurrT);
} catch (Exception ex) {
PerformanceAnalyzerApp.ERRORS_AND_EXCEPTIONS_AGGREGATOR.updateStat(
ExceptionsAndErrors.CLUSTER_APPLIER_SERVICE_STATS_COLLECTOR_ERROR, "", 1);
LOG.debug(
"Exception in Collecting Cluster Applier Service Metrics: {} for startTime {}",
() -> ex.toString(),
() -> startTime);
}
}