Skip to content

Commit

Permalink
Merge pull request Netflix#775 from mattrjacobs/add-counters-for-hyst…
Browse files Browse the repository at this point in the history
…rix-quantities

Add HystrixCounters methods to return number of commands/threadpools/groups
  • Loading branch information
mattrjacobs committed Apr 29, 2015
2 parents f5a605f + f94ce74 commit 473a531
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,9 @@ public String name() {
}

}

/* package-private */ static int getGroupCount() {
return intern.size();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public String name() {
}

}

/* package-private */ static int getCommandCount() {
return intern.size();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import java.util.concurrent.atomic.AtomicInteger;

/**
* Class with global statistics on Hystrix runtime behavior.
* All of the data available via this class is static and scoped at the JVM level
*/
public class HystrixCounters {
private static final AtomicInteger concurrentThreadsExecuting = new AtomicInteger(0);

Expand All @@ -13,7 +17,35 @@ public class HystrixCounters {
concurrentThreadsExecuting.decrementAndGet();
}

/**
* Return the number of currently-executing Hystrix threads
* @return number of currently-executing Hystrix threads
*/
public static int getGlobalConcurrentThreadsExecuting() {
return concurrentThreadsExecuting.get();
}

/**
* Return the number of unique {@link HystrixCommand}s that have been registered
* @return number of unique {@link HystrixCommand}s that have been registered
*/
public static int getCommandCount() {
return HystrixCommandKey.Factory.getCommandCount();
}

/**
* Return the number of unique {@link HystrixThreadPool}s that have been registered
* @return number of unique {@link HystrixThreadPool}s that have been registered
*/
public static int getThreadPoolCount() {
return HystrixThreadPoolKey.Factory.getThreadPoolCount();
}

/**
* Return the number of unique {@link HystrixCommandGroupKey}s that have been registered
* @return number of unique {@link HystrixCommandGroupKey}s that have been registered
*/
public static int getGroupCount() {
return HystrixCommandGroupKey.Factory.getGroupCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,9 @@ public String name() {
}

}

/* package-private */ static int getThreadPoolCount() {
return intern.size();
}
}
}

0 comments on commit 473a531

Please sign in to comment.