Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Added metrics publishing logic (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
psychbot authored Mar 4, 2021
1 parent 819d485 commit a997189
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.amazon.opendistro.elasticsearch.performanceanalyzer.collectors;

import com.amazon.opendistro.elasticsearch.performanceanalyzer.ESResources;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.PerformanceAnalyzerApp;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.PerformanceAnalyzerController;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.overrides.ConfigOverridesWrapper;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics;
Expand All @@ -24,6 +25,8 @@
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.MetricsConfiguration;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.MetricsProcessor;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.PerformanceAnalyzerMetrics;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.metrics.ExceptionsAndErrors;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.metrics.WriterMetrics;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -76,6 +79,7 @@ public void collectMetrics(long startTime) {
return;
}

long mCurrT = System.currentTimeMillis();
try {
ClusterService clusterService = ESResources.INSTANCE.getClusterService();
if (clusterService != null) {
Expand Down Expand Up @@ -124,11 +128,18 @@ public void collectMetrics(long startTime) {
});
}
}
} catch (NoSuchFieldException | IllegalAccessException | ClassNotFoundException e) {
LOG.debug("Exception raised. Skipping IndexingPressureMetricsCollector");
if(value.length() != 0) {
saveMetricValues(value.toString(), startTime);
PerformanceAnalyzerApp.WRITER_METRICS_AGGREGATOR.updateStat(
WriterMetrics.SHARD_INDEXING_PRESSURE_COLLECTOR_EXECUTION_TIME, "",
System.currentTimeMillis() - mCurrT);
}
} catch (Exception ex) {
PerformanceAnalyzerApp.ERRORS_AND_EXCEPTIONS_AGGREGATOR.updateStat(
ExceptionsAndErrors.SHARD_INDEXING_PRESSURE_COLLECTOR_ERROR, "", 1);
LOG.debug("Exception in Collecting Shard Indexing Pressure Metrics: {} for startTime {}", () -> ex.toString(), () -> startTime);
}

saveMetricValues(value.toString(), startTime);
}

Field getField(String className, String fieldName) throws NoSuchFieldException, ClassNotFoundException {
Expand Down

0 comments on commit a997189

Please sign in to comment.