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

Commit

Permalink
Shibaili master metrics (#15)
Browse files Browse the repository at this point in the history
Merge in master metrics
  • Loading branch information
shibaili-amazon authored Apr 4, 2019
1 parent ab7dea9 commit d195d44
Show file tree
Hide file tree
Showing 8 changed files with 844 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor;

import com.amazon.opendistro.elasticsearch.performanceanalyzer.ESResources;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.Master_Metric_Dimensions;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.Master_Metric_Values;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.MasterMetricDimensions;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.MasterMetricValues;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.MetricsConfiguration;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.MetricsProcessor;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.ThreadIDUtil;
Expand Down Expand Up @@ -107,17 +107,17 @@ public void collectMetrics(long startTime) {
lastTaskInsertionOrder = firstPending.insertionOrder;
int firstSpaceIndex = task.source().indexOf(" ");
value.append(PerformanceAnalyzerMetrics.getCurrentTimeMetric());
PerformanceAnalyzerMetrics.addMetricEntry(value, Master_Metric_Dimensions.MASTER_TASK_PRIORITY.toString(),
PerformanceAnalyzerMetrics.addMetricEntry(value, MasterMetricDimensions.MASTER_TASK_PRIORITY.toString(),
firstPending.priority.toString());
//- as it is sampling, we won't exactly know the start time of the current task, we will be
//- capturing start time as midpoint of previous time bucket
PerformanceAnalyzerMetrics.addMetricEntry(value, Master_Metric_Values.START_TIME.toString(),
PerformanceAnalyzerMetrics.addMetricEntry(value, MasterMetricValues.START_TIME.toString(),
startTime - SAMPLING_TIME_INTERVAL / 2);
PerformanceAnalyzerMetrics.addMetricEntry(value, Master_Metric_Dimensions.MASTER_TASK_TYPE.toString(),
PerformanceAnalyzerMetrics.addMetricEntry(value, MasterMetricDimensions.MASTER_TASK_TYPE.toString(),
firstSpaceIndex == -1 ? task.source() : task.source().substring(0, firstSpaceIndex));
PerformanceAnalyzerMetrics.addMetricEntry(value, Master_Metric_Dimensions.MASTER_TASK_METADATA.toString(),
PerformanceAnalyzerMetrics.addMetricEntry(value, MasterMetricDimensions.MASTER_TASK_METADATA.toString(),
firstSpaceIndex == -1 ? "" : task.source().substring(firstSpaceIndex));
PerformanceAnalyzerMetrics.addMetricEntry(value, Master_Metric_Dimensions.MASTER_TASK_AGE.toString(),
PerformanceAnalyzerMetrics.addMetricEntry(value, MasterMetricDimensions.MASTER_TASK_QUEUE_TIME.toString(),
task.getAgeInMillis());

saveMetricValues(value.toString(), startTime, String.valueOf(getMasterThreadId()),
Expand All @@ -137,7 +137,7 @@ public void collectMetrics(long startTime) {
private void generateFinishMetrics(long startTime) {
if (lastTaskInsertionOrder != -1) {
value.append(PerformanceAnalyzerMetrics.getCurrentTimeMetric());
PerformanceAnalyzerMetrics.addMetricEntry(value, Master_Metric_Values.FINISH_TIME.toString(),
PerformanceAnalyzerMetrics.addMetricEntry(value, MasterMetricValues.FINISH_TIME.toString(),
startTime - SAMPLING_TIME_INTERVAL / 2);
saveMetricValues(value.toString(), startTime, String.valueOf(currentThreadId),
String.valueOf(lastTaskInsertionOrder), PerformanceAnalyzerMetrics.FINISH_FILE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,15 +576,17 @@ public static class Constants {
}
}

public enum Master_Metric_Dimensions implements MetricDimension {
MASTER_TASK_PRIORITY("Master_Task_Priority"),
MASTER_TASK_TYPE("Master_Task_Type"),
MASTER_TASK_METADATA("Master_Task_Metadata"),
MASTER_TASK_AGE("Master_Task_Age");
public enum MasterMetricDimensions implements MetricDimension {
MASTER_TASK_PRIORITY("MasterTaskPriority"),
MASTER_TASK_TYPE("MasterTaskType"),
MASTER_TASK_METADATA("MasterTaskMetadata"),
MASTER_TASK_QUEUE_TIME("MasterTaskQueueTime"),
MASTER_TASK_RUN_TIME("MasterTaskRunTime"),
MASTER_TASK_INSERT_ORDER("MasterTaskInsertOrder");

private final String value;

Master_Metric_Dimensions(String value) {
MasterMetricDimensions(String value) {
this.value = value;
}

Expand All @@ -594,14 +596,16 @@ public String toString() {
}
}

public enum Master_Metric_Values implements MetricValue {
public enum MasterMetricValues implements MetricValue {
//-todo : Migrate to CommonMetric.Constants
MASTER_TASK_QUEUE_TIME("Master_Task_Queue_Time"),
MASTER_TASK_RUN_TIME("Master_Task_Run_Time"),
START_TIME("StartTime"),
FINISH_TIME("FinishTime");

private final String value;

Master_Metric_Values(String value) {
MasterMetricValues(String value) {
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.Map;

import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.AggregatedOSDimension;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.CircuitBreakerDimension;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.CircuitBreakerValue;
Expand Down Expand Up @@ -227,5 +228,11 @@ public class MetricsModel {
// Master Metrics
ALL_METRICS.put(MasterPendingValue.MASTER_PENDING_QUEUE_SIZE.toString(),
new MetricAttributes(MetricUnits.COUNT.toString(), EmptyDimension.values()));

ALL_METRICS.put(AllMetrics.MasterMetricValues.MASTER_TASK_QUEUE_TIME.toString(),
new MetricAttributes(MetricUnits.MILLISECOND.toString(), AllMetrics.MasterMetricDimensions.values()));

ALL_METRICS.put(AllMetrics.MasterMetricValues.MASTER_TASK_RUN_TIME.toString(),
new MetricAttributes(MetricUnits.MILLISECOND.toString(), AllMetrics.MasterMetricDimensions.values()));
}
}
Loading

0 comments on commit d195d44

Please sign in to comment.