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

Filter out thread pools from metrics stream that have had no commands executed on them #738

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ public void run() {
}

for (HystrixThreadPoolMetrics threadPoolMetrics : HystrixThreadPoolMetrics.getInstances()) {
String jsonString = getThreadPoolJson(threadPoolMetrics);
listener.handleJsonMetric(jsonString);
if (hasExecutedCommandsOnThread(threadPoolMetrics)) {
String jsonString = getThreadPoolJson(threadPoolMetrics);
listener.handleJsonMetric(jsonString);
}
}

for (HystrixCollapserMetrics collapserMetrics : HystrixCollapserMetrics.getInstances()) {
Expand Down Expand Up @@ -292,6 +294,10 @@ private String getCommandJson(HystrixCommandMetrics commandMetrics) throws IOExc
return jsonString.getBuffer().toString();
}

private boolean hasExecutedCommandsOnThread(HystrixThreadPoolMetrics threadPoolMetrics) {
return threadPoolMetrics.getCurrentCompletedTaskCount().intValue() > 0;
}

private String getThreadPoolJson(HystrixThreadPoolMetrics threadPoolMetrics) throws IOException {
HystrixThreadPoolKey key = threadPoolMetrics.getThreadPoolKey();
StringWriter jsonString = new StringWriter();
Expand Down