-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 2.x] changes to merge PA-RTF (#662)
* changes to merge PA-RTF (#651) * PA RTF merging init Signed-off-by: Atharva Sharma <[email protected]> * working model Signed-off-by: Atharva Sharma <[email protected]> * working model tip Signed-off-by: Atharva Sharma <[email protected]> * functional model init Signed-off-by: Atharva Sharma <[email protected]> * Migrated HeapMetricsCollector Signed-off-by: Atharva Sharma <[email protected]> * Added RTFThreadPoolMetricsCollector Signed-off-by: Atharva Sharma <[email protected]> * migrated NodeStats and DiskMetricsCollector Signed-off-by: Atharva Sharma <[email protected]> * Added gauge data model for Heap_Max metric Signed-off-by: Atharva Sharma <[email protected]> * implemented TelemetryAwarePlugin Signed-off-by: Atharva Sharma <[email protected]> * Framework changes for PA RTF merging Signed-off-by: Atharva Sharma <[email protected]> * refactored Signed-off-by: Atharva Sharma <[email protected]> * spotless applied Signed-off-by: Atharva Sharma <[email protected]> * Addressed small comments Signed-off-by: Atharva Sharma <[email protected]> * Added different flag for RCA collectors Signed-off-by: Atharva Sharma <[email protected]> * Addressed more comments Signed-off-by: Atharva Sharma <[email protected]> * Added RTF collectors in config map Signed-off-by: Atharva Sharma <[email protected]> * Added UTs Signed-off-by: Atharva Sharma <[email protected]> * Added further UTs Signed-off-by: Atharva Sharma <[email protected]> * Added dynamic control support to all collectors Signed-off-by: Atharva Sharma <[email protected]> * fixed UT Signed-off-by: Atharva Sharma <[email protected]> * refactoring Signed-off-by: Atharva Sharma <[email protected]> * Revert "refactoring" This reverts commit 25d66e8. Signed-off-by: Atharva Sharma <[email protected]> * Revert "fixed UT" This reverts commit 369bd95. Signed-off-by: Atharva Sharma <[email protected]> * Revert "Added dynamic control support to all collectors" This reverts commit 447e15f. Signed-off-by: Atharva Sharma <[email protected]> * Adding two new collector interfaces Signed-off-by: Atharva Sharma <[email protected]> * simplified interfaces Signed-off-by: Atharva Sharma <[email protected]> * Added units and javadocs Signed-off-by: Atharva Sharma <[email protected]> * Changes metrics semantic conventions Signed-off-by: Atharva Sharma <[email protected]> * refactored Signed-off-by: Atharva Sharma <[email protected]> * fixed UT Signed-off-by: Atharva Sharma <[email protected]> * Added stats metrics for rtf collectors Signed-off-by: Atharva Sharma <[email protected]> * reverted test delete Signed-off-by: Atharva Sharma <[email protected]> * Fixes javadoc compilation issue Signed-off-by: Gagan Juneja <[email protected]> --------- Signed-off-by: Atharva Sharma <[email protected]> Signed-off-by: Gagan Juneja <[email protected]> Co-authored-by: Gagan Juneja <[email protected]> * Empty-Commit Signed-off-by: Dev Agarwal <[email protected]> --------- Signed-off-by: Atharva Sharma <[email protected]> Signed-off-by: Gagan Juneja <[email protected]> Signed-off-by: Dev Agarwal <[email protected]> Co-authored-by: Atharva Sharma <[email protected]> Co-authored-by: Gagan Juneja <[email protected]>
- Loading branch information
1 parent
df8947e
commit 84379d5
Showing
20 changed files
with
1,512 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
src/main/java/org/opensearch/performanceanalyzer/collectors/telemetry/RTFDisksCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.performanceanalyzer.collectors.telemetry; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.performanceanalyzer.OpenSearchResources; | ||
import org.opensearch.performanceanalyzer.commons.OSMetricsGeneratorFactory; | ||
import org.opensearch.performanceanalyzer.commons.collectors.PerformanceAnalyzerMetricsCollector; | ||
import org.opensearch.performanceanalyzer.commons.collectors.TelemetryCollector; | ||
import org.opensearch.performanceanalyzer.commons.config.overrides.ConfigOverridesWrapper; | ||
import org.opensearch.performanceanalyzer.commons.metrics.MetricsConfiguration; | ||
import org.opensearch.performanceanalyzer.commons.metrics.RTFMetrics; | ||
import org.opensearch.performanceanalyzer.commons.metrics_generator.DiskMetricsGenerator; | ||
import org.opensearch.performanceanalyzer.commons.metrics_generator.OSMetricsGenerator; | ||
import org.opensearch.performanceanalyzer.commons.stats.metrics.StatExceptionCode; | ||
import org.opensearch.performanceanalyzer.commons.stats.metrics.StatMetrics; | ||
import org.opensearch.performanceanalyzer.config.PerformanceAnalyzerController; | ||
import org.opensearch.telemetry.metrics.Histogram; | ||
import org.opensearch.telemetry.metrics.MetricsRegistry; | ||
import org.opensearch.telemetry.metrics.tags.Tags; | ||
|
||
public class RTFDisksCollector extends PerformanceAnalyzerMetricsCollector | ||
implements TelemetryCollector { | ||
|
||
private Histogram diskWaitTimeMetrics; | ||
private Histogram diskServiceRateMetrics; | ||
private Histogram diskUtilizationMetrics; | ||
private MetricsRegistry metricsRegistry; | ||
private boolean metricsInitialised; | ||
private static final Logger LOG = LogManager.getLogger(RTFDisksCollector.class); | ||
private PerformanceAnalyzerController performanceAnalyzerController; | ||
private ConfigOverridesWrapper configOverridesWrapper; | ||
|
||
public RTFDisksCollector( | ||
PerformanceAnalyzerController performanceAnalyzerController, | ||
ConfigOverridesWrapper configOverridesWrapper) { | ||
super( | ||
MetricsConfiguration.CONFIG_MAP.get(RTFDisksCollector.class).samplingInterval, | ||
"RTFDisksCollector", | ||
StatMetrics.RTF_DISKS_COLLECTOR_EXECUTION_TIME, | ||
StatExceptionCode.RTF_DISK_METRICS_COLLECTOR_ERROR); | ||
this.metricsInitialised = false; | ||
this.performanceAnalyzerController = performanceAnalyzerController; | ||
this.configOverridesWrapper = configOverridesWrapper; | ||
} | ||
|
||
@Override | ||
public void collectMetrics(long startTime) { | ||
if (performanceAnalyzerController.isCollectorDisabled( | ||
configOverridesWrapper, getCollectorName())) { | ||
LOG.info("RTFDisksCollector is disabled. Skipping collection."); | ||
return; | ||
} | ||
|
||
OSMetricsGenerator generator = OSMetricsGeneratorFactory.getInstance(); | ||
if (generator == null) { | ||
LOG.error("could not get the instance of OSMetricsGeneratorFactory class"); | ||
return; | ||
} | ||
|
||
metricsRegistry = OpenSearchResources.INSTANCE.getMetricsRegistry(); | ||
if (metricsRegistry == null) { | ||
LOG.error("could not get the instance of MetricsRegistry class"); | ||
return; | ||
} | ||
|
||
LOG.debug("Executing collect metrics for RTFDisksCollector"); | ||
|
||
initialiseMetricsIfNeeded(); | ||
DiskMetricsGenerator diskMetricsGenerator = generator.getDiskMetricsGenerator(); | ||
diskMetricsGenerator.addSample(); | ||
|
||
recordMetrics(diskMetricsGenerator); | ||
} | ||
|
||
public void recordMetrics(DiskMetricsGenerator diskMetricsGenerator) { | ||
for (String disk : diskMetricsGenerator.getAllDisks()) { | ||
Tags diskNameTag = | ||
Tags.create().addTag(RTFMetrics.DiskDimension.DISK_NAME.toString(), disk); | ||
double diskWaitTime = diskMetricsGenerator.getAwait(disk); | ||
double diskServiceRate = diskMetricsGenerator.getServiceRate(disk); | ||
double diskUtilization = diskMetricsGenerator.getDiskUtilization(disk); | ||
diskWaitTimeMetrics.record(diskWaitTime, diskNameTag); | ||
diskUtilizationMetrics.record(diskUtilization, diskNameTag); | ||
diskServiceRateMetrics.record(diskServiceRate, diskNameTag); | ||
} | ||
} | ||
|
||
private void initialiseMetricsIfNeeded() { | ||
if (metricsInitialised == false) { | ||
diskWaitTimeMetrics = | ||
metricsRegistry.createHistogram( | ||
RTFMetrics.DiskValue.Constants.WAIT_VALUE, | ||
"DiskWaitTimeMetrics", | ||
RTFMetrics.MetricUnits.MILLISECOND.toString()); | ||
diskServiceRateMetrics = | ||
metricsRegistry.createHistogram( | ||
RTFMetrics.DiskValue.Constants.SRATE_VALUE, | ||
"DiskServiceRateMetrics", | ||
RTFMetrics.MetricUnits.MEGABYTE_PER_SEC.toString()); | ||
diskUtilizationMetrics = | ||
metricsRegistry.createHistogram( | ||
RTFMetrics.DiskValue.Constants.UTIL_VALUE, | ||
"DiskUtilizationMetrics", | ||
RTFMetrics.MetricUnits.PERCENT.toString()); | ||
metricsInitialised = true; | ||
} | ||
} | ||
} |
Oops, something went wrong.