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

Added metrics publishing logic #285

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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