-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
StatsCollector, Aggregators, MetricsConfiguration move
- Loading branch information
Showing
35 changed files
with
2,036 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://www.envoyproxy.io/ |
104 changes: 104 additions & 0 deletions
104
...pensearch/performanceanalyzer/commons/collectors/PerformanceAnalyzerMetricsCollector.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,104 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.performanceanalyzer.commons.collectors; | ||
|
||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.performanceanalyzer.commons.util.Util; | ||
|
||
public abstract class PerformanceAnalyzerMetricsCollector implements Runnable { | ||
enum State { | ||
HEALTHY, | ||
|
||
// This collector could not complete between two runs of | ||
// ScheduledMetricCollectorsExecutor. First occurrence of | ||
// this is considered a warning. | ||
SLOW, | ||
|
||
// A collector is muted if it failed to complete between two runs of | ||
// ScheduledMetricCollectorsExecutor. A muted collector is skipped. | ||
MUTED | ||
} | ||
|
||
private static final Logger LOG = | ||
LogManager.getLogger(PerformanceAnalyzerMetricsCollector.class); | ||
private int timeInterval; | ||
private long startTime; | ||
private String collectorName; | ||
protected StringBuilder value; | ||
protected State state; | ||
private boolean threadContentionMonitoringEnabled; | ||
|
||
protected PerformanceAnalyzerMetricsCollector(int timeInterval, String collectorName) { | ||
this.timeInterval = timeInterval; | ||
this.collectorName = collectorName; | ||
this.value = new StringBuilder(); | ||
this.state = State.HEALTHY; | ||
} | ||
|
||
private AtomicBoolean bInProgress = new AtomicBoolean(false); | ||
|
||
public int getTimeInterval() { | ||
return timeInterval; | ||
} | ||
|
||
public boolean inProgress() { | ||
return bInProgress.get(); | ||
} | ||
|
||
public String getCollectorName() { | ||
return collectorName; | ||
} | ||
|
||
abstract void collectMetrics(long startTime); | ||
|
||
public void setStartTime(long startTime) { | ||
this.startTime = startTime; | ||
bInProgress.set(true); | ||
} | ||
|
||
public void run() { | ||
try { | ||
Util.invokePrivileged(() -> collectMetrics(startTime)); | ||
} catch (Exception ex) { | ||
// - should not be any...but in case, absorbing here | ||
// - logging...we shouldn't be doing as it will slow down; as well as fill up the log. | ||
// Need to | ||
// find a way to catch these | ||
LOG.error( | ||
"Error In Collect Metrics: {} with ExceptionCode: {}", | ||
() -> ex.toString(), | ||
() -> StatExceptionCode.OTHER_COLLECTION_ERROR.toString()); | ||
StatsCollector.instance().logException(StatExceptionCode.OTHER_COLLECTION_ERROR); | ||
} finally { | ||
bInProgress.set(false); | ||
} | ||
} | ||
|
||
@VisibleForTesting | ||
public StringBuilder getValue() { | ||
return value; | ||
} | ||
|
||
public State getState() { | ||
return state; | ||
} | ||
|
||
public void setState(State state) { | ||
this.state = state; | ||
} | ||
|
||
public void setThreadContentionMonitoringEnabled(boolean enabled) { | ||
this.threadContentionMonitoringEnabled = enabled; | ||
} | ||
|
||
public boolean getThreadContentionMonitoringEnabled() { | ||
return threadContentionMonitoringEnabled; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/org/opensearch/performanceanalyzer/commons/collectors/StatExceptionCode.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,60 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.performanceanalyzer.commons.collectors; | ||
|
||
public enum StatExceptionCode { | ||
TOTAL_ERROR("TotalError"), | ||
|
||
// Tracks the number of VM attach/dataDump or detach failures. | ||
JVM_ATTACH_ERROR("JvmAttachErrror"), | ||
|
||
// This error is thrown if the java_pid file is missing. | ||
JVM_ATTACH_ERROR_JAVA_PID_FILE_MISSING("JvmAttachErrorJavaPidFileMissing"), | ||
|
||
// The lock could not be acquired within the timeout. | ||
JVM_ATTACH_LOCK_ACQUISITION_FAILED("JvmAttachLockAcquisitionFailed"), | ||
|
||
// ThreadState could not be found for an OpenSearch thread in the critical OpenSearch path. | ||
NO_THREAD_STATE_INFO("NoThreadStateInfo"), | ||
|
||
// This metric indicates that we successfully completed a thread-dump. Likewise, | ||
// an omission of this should indicate that the thread taking the dump got stuck. | ||
JVM_THREAD_DUMP_SUCCESSFUL("JvmThreadDumpSuccessful"), | ||
COLLECTORS_MUTED("CollectorsMutedCount"), | ||
CLUSTER_MANAGER_METRICS_ERROR("ClusterManagerMetricsError"), | ||
DISK_METRICS_ERROR("DiskMetricsError"), | ||
THREAD_IO_ERROR("ThreadIOError"), | ||
SCHEMA_PARSER_ERROR("SchemaParserError"), | ||
JSON_PARSER_ERROR("JsonParserError"), | ||
NETWORK_COLLECTION_ERROR("NetworkCollectionError"), | ||
NODESTATS_COLLECTION_ERROR("NodeStatsCollectionError"), | ||
OTHER_COLLECTION_ERROR("OtherCollectionError"), | ||
REQUEST_ERROR("RequestError"), | ||
REQUEST_REMOTE_ERROR("RequestRemoteError"), | ||
READER_PARSER_ERROR("ReaderParserError"), | ||
READER_RESTART_PROCESSING("ReaderRestartProcessing"), | ||
RCA_SCHEDULER_RESTART_PROCESSING("RCASchedulerRestartProcessing"), | ||
RCA_NETWORK_ERROR("RcaNetworkError"), | ||
RCA_VERTEX_RX_BUFFER_FULL_ERROR("RcaVertexRxBufferFullError"), | ||
RCA_NETWORK_THREADPOOL_QUEUE_FULL_ERROR("RcaNetworkThreadpoolQueueFullError"), | ||
RCA_SCHEDULER_STOPPED_ERROR("RcaSchedulerStoppedError"), | ||
OPENSEARCH_REQUEST_INTERCEPTOR_ERROR("OpenSearchRequestInterceptorError"), | ||
MISCONFIGURED_OLD_GEN_RCA_HEAP_MAX_MISSING("MisconfiguredOldGenRcaHeapMaxMissing"), | ||
MISCONFIGURED_OLD_GEN_RCA_HEAP_USED_MISSING("MisconfiguredOldGenRcaHeapUsedMissing"), | ||
MISCONFIGURED_OLD_GEN_RCA_GC_EVENTS_MISSING("MisconfiguredOldGenRcaGcEventsMissing"), | ||
TOTAL_MEM_READ_ERROR("TotalMemReadError"); | ||
|
||
private final String value; | ||
|
||
StatExceptionCode(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
} |
Oops, something went wrong.