Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StatsCollector, Aggregators, MetricsConfiguration move #6

Merged
merged 5 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .lychee.excludes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://www.envoyproxy.io/
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;
}
}
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;
}
}
Loading