Skip to content

Commit

Permalink
Added a rolling max counter for command execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Jacobs committed Feb 10, 2015
1 parent 8a209d8 commit 5c12927
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ public class HystrixMetricsPoller {
* <p>
* Use <code>pause</code> to temporarily stop polling that can be restarted again with <code>start</code>.
*
* @param MetricsAsJsonPollerListener
* for callbacks
* @param listener for callbacks
* @param delay
*/
public HystrixMetricsPoller(MetricsAsJsonPollerListener listener, int delay) {
Expand Down Expand Up @@ -221,6 +220,7 @@ private String getCommandJson(HystrixCommandMetrics commandMetrics) throws IOExc
json.writeNumberField("rollingCountTimeout", commandMetrics.getRollingCount(HystrixRollingNumberEvent.TIMEOUT));

json.writeNumberField("currentConcurrentExecutionCount", commandMetrics.getCurrentConcurrentExecutionCount());
json.writeNumberField("rollingMaxConcurrentExecutionCount", commandMetrics.getRollingMaxConcurrentExecutions());

// latency percentiles
json.writeNumberField("latencyExecute_mean", commandMetrics.getExecutionTimeMean());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static String toJson(HystrixCommandMetrics commandMetrics) throws IOException {
json.writeNumberField("rollingCountTimeout", commandMetrics.getRollingCount(HystrixRollingNumberEvent.TIMEOUT));

json.writeNumberField("currentConcurrentExecutionCount", commandMetrics.getCurrentConcurrentExecutionCount());
json.writeNumberField("rollingMaxConcurrentExecutionCount", commandMetrics.getRollingMaxConcurrentExecutions());

// latency percentiles
json.writeNumberField("latencyExecute_mean", commandMetrics.getExecutionTimeMean());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public void call() {
*/
private Observable<R> getRunObservableDecoratedForMetricsAndErrorHandling() {
final AbstractCommand<R> _self = this;
// allow tracking how many concurrent threads are executing
// allow tracking how many concurrent commands are executing
metrics.incrementConcurrentExecutionCount();

final HystrixRequestContext currentRequestContext = HystrixRequestContext.getContextForCurrentThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,22 +288,23 @@ public int getCurrentConcurrentExecutionCount() {

/**
* Increment concurrent requests counter.
*
* @param numberOfPermitsUsed
*/
/* package */void incrementConcurrentExecutionCount() {
concurrentExecutionCount.incrementAndGet();
int numConcurrent = concurrentExecutionCount.incrementAndGet();
counter.updateRollingMax(HystrixRollingNumberEvent.COMMAND_MAX_ACTIVE, (long) numConcurrent);
}

/**
* Increment concurrent requests counter.
*
* @param numberOfPermitsUsed
* Decrement concurrent requests counter.
*/
/* package */void decrementConcurrentExecutionCount() {
concurrentExecutionCount.decrementAndGet();
}

public long getRollingMaxConcurrentExecutions() {
return counter.getRollingMaxValue(HystrixRollingNumberEvent.COMMAND_MAX_ACTIVE);
}

/**
* When a {@link HystrixCommand} returns a Fallback successfully.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public enum HystrixRollingNumberEvent {
SUCCESS(1), FAILURE(1), TIMEOUT(1), SHORT_CIRCUITED(1), THREAD_POOL_REJECTED(1), SEMAPHORE_REJECTED(1), BAD_REQUEST(1),
FALLBACK_SUCCESS(1), FALLBACK_FAILURE(1), FALLBACK_REJECTION(1), EXCEPTION_THROWN(1),
FALLBACK_SUCCESS(1), FALLBACK_FAILURE(1), FALLBACK_REJECTION(1), EXCEPTION_THROWN(1), COMMAND_MAX_ACTIVE(2),
THREAD_EXECUTION(1), THREAD_MAX_ACTIVE(2), COLLAPSED(1), RESPONSE_FROM_CACHE(1),
COLLAPSER_REQUEST_BATCHED(1), COLLAPSER_BATCH(1);

Expand Down

0 comments on commit 5c12927

Please sign in to comment.