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

Commit

Permalink
collect queue capacity on writer (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
rguo-aws authored Jun 19, 2020
1 parent 8583570 commit 976e132
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion licenses/performanceanalyzer-rca-1.3.jar.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7ab11a3251d4bd2b09ddca5a4f01e4ef3dbdc9ed
4ef70ce3a018f743a7a3a343f76ececd8e91fd18
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ public void collectMetrics(long startTime) {
//This is for backward compatibility. core ES may or may not emit latency metric
// (depending on whether the patch has been applied or not)
// so we need to use reflection to check whether getLatency() method exist in ThreadPoolStats.java.
// call stats.getLatency()
Method getLantencyMethod = Stats.class.getMethod("getLatency");
double latency = (Double) getLantencyMethod.invoke(stats);
// call stats.getCapacity()
Method getCapacityMethod = Stats.class.getMethod("getCapacity");
int capacity = (Integer) getCapacityMethod.invoke(stats);
return new ThreadPoolStatus(stats.getName(),
stats.getQueue(), stats.getRejected(),
stats.getThreads(), stats.getActive(), latency);
stats.getThreads(), stats.getActive(),
latency, capacity);
} catch (Exception e) {
//core ES does not have the latency patch. send the threadpool metrics without adding latency.
return new ThreadPoolStatus(stats.getName(),
Expand Down Expand Up @@ -93,6 +98,8 @@ public static class ThreadPoolStatus extends MetricStatus {
public final int threadsActive;
@JsonInclude(Include.NON_NULL)
public final Double queueLatency;
@JsonInclude(Include.NON_NULL)
public final Integer queueCapacity;

public ThreadPoolStatus(String type,
int queueSize,
Expand All @@ -105,20 +112,23 @@ public ThreadPoolStatus(String type,
this.threadsCount = threadsCount;
this.threadsActive = threadsActive;
this.queueLatency = null;
this.queueCapacity = null;
}

public ThreadPoolStatus(String type,
int queueSize,
long rejected,
int threadsCount,
int threadsActive,
double queueLatency) {
double queueLatency,
int queueCapacity) {
this.type = type;
this.queueSize = queueSize;
this.rejected = rejected;
this.threadsCount = threadsCount;
this.threadsActive = threadsActive;
this.queueLatency = queueLatency;
this.queueCapacity = queueCapacity;
}

@JsonProperty(ThreadPoolDimension.Constants.TYPE_VALUE)
Expand Down Expand Up @@ -150,5 +160,10 @@ public int getThreadsActive() {
public Double getQueueLatency() {
return queueLatency;
}

@JsonProperty(ThreadPoolValue.Constants.QUEUE_CAPACITY_VALUE)
public Integer getQueueCapacity() {
return queueCapacity;
}
}
}

0 comments on commit 976e132

Please sign in to comment.