test_class.declarator: ctx = new HystrixRequestContextRule()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public HystrixRequestContextRule ctx = new HystrixRequestContextRule();
test_class.type: HystrixRequestContextRule
test_class.var_name: ctx
test_class.file: hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandMetricsTest.java
test_class.identifier: HystrixCommandMetricsTest
test_case.body: @Test
      public void testGetErrorPercentage() {
          String key = "cmd-metrics-A";
          try {
              HystrixCommand<Boolean> cmd1 = new SuccessCommand(key, 1);
              HystrixCommandMetrics metrics = cmd1.metrics;
              cmd1.execute();
              Thread.sleep(100);
              assertEquals(0, metrics.getHealthCounts().getErrorPercentage());
  
              HystrixCommand<Boolean> cmd2 = new FailureCommand(key, 1);
              cmd2.execute();
              Thread.sleep(100);
              assertEquals(50, metrics.getHealthCounts().getErrorPercentage());
  
              HystrixCommand<Boolean> cmd3 = new SuccessCommand(key, 1);
              HystrixCommand<Boolean> cmd4 = new SuccessCommand(key, 1);
              cmd3.execute();
              cmd4.execute();
              Thread.sleep(100);
              assertEquals(25, metrics.getHealthCounts().getErrorPercentage());
  
              HystrixCommand<Boolean> cmd5 = new TimeoutCommand(key);
              HystrixCommand<Boolean> cmd6 = new TimeoutCommand(key);
              cmd5.execute();
              cmd6.execute();
              Thread.sleep(100);
              assertEquals(50, metrics.getHealthCounts().getErrorPercentage());
  
              HystrixCommand<Boolean> cmd7 = new SuccessCommand(key, 1);
              HystrixCommand<Boolean> cmd8 = new SuccessCommand(key, 1);
              HystrixCommand<Boolean> cmd9 = new SuccessCommand(key, 1);
              cmd7.execute();
              cmd8.execute();
              cmd9.execute();
  
              // latent
              HystrixCommand<Boolean> cmd10 = new SuccessCommand(key, 60);
              cmd10.execute();
  
              // 6 success + 1 latent success + 1 failure + 2 timeout = 10 total
              // latent success not considered error
              // error percentage = 1 failure + 2 timeout / 10
              Thread.sleep(100);
              assertEquals(30, metrics.getHealthCounts().getErrorPercentage());
  
          } catch (Exception e) {
              e.printStackTrace();
              fail("Error occurred: " + e.getMessage());
          }
  
      }
test_case.class_method_signature: HystrixCommandMetricsTest.testGetErrorPercentage()
test_case.full_signature: @Test public void testGetErrorPercentage()
test_case.identifier: testGetErrorPercentage
test_case.invocations: execute sleep assertEquals getErrorPercentage getHealthCounts execute sleep assertEquals getErrorPercentage getHealthCounts execute execute sleep assertEquals getErrorPercentage getHealthCounts execute execute sleep assertEquals getErrorPercentage getHealthCounts execute execute execute execute sleep assertEquals getErrorPercentage getHealthCounts printStackTrace fail getMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetErrorPercentage()
focal_class.declarator: logger = LoggerFactory.getLogger(HystrixCommandMetrics.class)
focal_class.modifier: @SuppressWarnings("unused")
      private static final
focal_class.original_string: @SuppressWarnings("unused")
      private static final Logger logger = LoggerFactory.getLogger(HystrixCommandMetrics.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: ALL_EVENT_TYPES = HystrixEventType.values()
focal_class.modifier: private static final
focal_class.original_string: private static final HystrixEventType[] ALL_EVENT_TYPES = HystrixEventType.values();
focal_class.type: HystrixEventType[]
focal_class.var_name: ALL_EVENT_TYPES
focal_class.declarator: appendEventToBucket = new Func2<long[], HystrixCommandCompletion, long[]>() {
          @Override
          public long[] call(long[] initialCountArray, HystrixCommandCompletion execution) {
              ExecutionResult.EventCounts eventCounts = execution.getEventCounts();
              for (HystrixEventType eventType: ALL_EVENT_TYPES) {
                  switch (eventType) {
                      case EXCEPTION_THROWN: break; //this is just a sum of other anyway - don't do the work here
                      default:
                          initialCountArray[eventType.ordinal()] += eventCounts.getCount(eventType);
                          break;
                  }
              }
              return initialCountArray;
          }
      }
focal_class.modifier: public static final
focal_class.original_string: public static final Func2<long[], HystrixCommandCompletion, long[]> appendEventToBucket = new Func2<long[], HystrixCommandCompletion, long[]>() {
          @Override
          public long[] call(long[] initialCountArray, HystrixCommandCompletion execution) {
              ExecutionResult.EventCounts eventCounts = execution.getEventCounts();
              for (HystrixEventType eventType: ALL_EVENT_TYPES) {
                  switch (eventType) {
                      case EXCEPTION_THROWN: break; //this is just a sum of other anyway - don't do the work here
                      default:
                          initialCountArray[eventType.ordinal()] += eventCounts.getCount(eventType);
                          break;
                  }
              }
              return initialCountArray;
          }
      };
focal_class.type: Func2<long[], HystrixCommandCompletion, long[]>
focal_class.var_name: appendEventToBucket
focal_class.declarator: bucketAggregator = new Func2<long[], long[], long[]>() {
          @Override
          public long[] call(long[] cumulativeEvents, long[] bucketEventCounts) {
              for (HystrixEventType eventType: ALL_EVENT_TYPES) {
                  switch (eventType) {
                      case EXCEPTION_THROWN:
                          for (HystrixEventType exceptionEventType: HystrixEventType.EXCEPTION_PRODUCING_EVENT_TYPES) {
                              cumulativeEvents[eventType.ordinal()] += bucketEventCounts[exceptionEventType.ordinal()];
                          }
                          break;
                      default:
                          cumulativeEvents[eventType.ordinal()] += bucketEventCounts[eventType.ordinal()];
                          break;
                  }
              }
              return cumulativeEvents;
          }
      }
focal_class.modifier: public static final
focal_class.original_string: public static final Func2<long[], long[], long[]> bucketAggregator = new Func2<long[], long[], long[]>() {
          @Override
          public long[] call(long[] cumulativeEvents, long[] bucketEventCounts) {
              for (HystrixEventType eventType: ALL_EVENT_TYPES) {
                  switch (eventType) {
                      case EXCEPTION_THROWN:
                          for (HystrixEventType exceptionEventType: HystrixEventType.EXCEPTION_PRODUCING_EVENT_TYPES) {
                              cumulativeEvents[eventType.ordinal()] += bucketEventCounts[exceptionEventType.ordinal()];
                          }
                          break;
                      default:
                          cumulativeEvents[eventType.ordinal()] += bucketEventCounts[eventType.ordinal()];
                          break;
                  }
              }
              return cumulativeEvents;
          }
      };
focal_class.type: Func2<long[], long[], long[]>
focal_class.var_name: bucketAggregator
focal_class.declarator: metrics = new ConcurrentHashMap<String, HystrixCommandMetrics>()
focal_class.modifier: private static final
focal_class.original_string: private static final ConcurrentHashMap<String, HystrixCommandMetrics> metrics = new ConcurrentHashMap<String, HystrixCommandMetrics>();
focal_class.type: ConcurrentHashMap<String, HystrixCommandMetrics>
focal_class.var_name: metrics
focal_class.declarator: properties
focal_class.modifier: private final
focal_class.original_string: private final HystrixCommandProperties properties;
focal_class.type: HystrixCommandProperties
focal_class.var_name: properties
focal_class.declarator: key
focal_class.modifier: private final
focal_class.original_string: private final HystrixCommandKey key;
focal_class.type: HystrixCommandKey
focal_class.var_name: key
focal_class.declarator: group
focal_class.modifier: private final
focal_class.original_string: private final HystrixCommandGroupKey group;
focal_class.type: HystrixCommandGroupKey
focal_class.var_name: group
focal_class.declarator: threadPoolKey
focal_class.modifier: private final
focal_class.original_string: private final HystrixThreadPoolKey threadPoolKey;
focal_class.type: HystrixThreadPoolKey
focal_class.var_name: threadPoolKey
focal_class.declarator: concurrentExecutionCount = new AtomicInteger()
focal_class.modifier: private final
focal_class.original_string: private final AtomicInteger concurrentExecutionCount = new AtomicInteger();
focal_class.type: AtomicInteger
focal_class.var_name: concurrentExecutionCount
focal_class.declarator: healthCountsStream
focal_class.modifier: private
focal_class.original_string: private HealthCountsStream healthCountsStream;
focal_class.type: HealthCountsStream
focal_class.var_name: healthCountsStream
focal_class.declarator: rollingCommandEventCounterStream
focal_class.modifier: private final
focal_class.original_string: private final RollingCommandEventCounterStream rollingCommandEventCounterStream;
focal_class.type: RollingCommandEventCounterStream
focal_class.var_name: rollingCommandEventCounterStream
focal_class.declarator: cumulativeCommandEventCounterStream
focal_class.modifier: private final
focal_class.original_string: private final CumulativeCommandEventCounterStream cumulativeCommandEventCounterStream;
focal_class.type: CumulativeCommandEventCounterStream
focal_class.var_name: cumulativeCommandEventCounterStream
focal_class.declarator: rollingCommandLatencyDistributionStream
focal_class.modifier: private final
focal_class.original_string: private final RollingCommandLatencyDistributionStream rollingCommandLatencyDistributionStream;
focal_class.type: RollingCommandLatencyDistributionStream
focal_class.var_name: rollingCommandLatencyDistributionStream
focal_class.declarator: rollingCommandUserLatencyDistributionStream
focal_class.modifier: private final
focal_class.original_string: private final RollingCommandUserLatencyDistributionStream rollingCommandUserLatencyDistributionStream;
focal_class.type: RollingCommandUserLatencyDistributionStream
focal_class.var_name: rollingCommandUserLatencyDistributionStream
focal_class.declarator: rollingCommandMaxConcurrencyStream
focal_class.modifier: private final
focal_class.original_string: private final RollingCommandMaxConcurrencyStream rollingCommandMaxConcurrencyStream;
focal_class.type: RollingCommandMaxConcurrencyStream
focal_class.var_name: rollingCommandMaxConcurrencyStream
focal_class.file: hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java
focal_class.identifier: HystrixCommandMetrics
focal_class.class_method_signature: HystrixCommandMetrics.getInstance(HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixCommandProperties properties)
focal_class.full_signature: public static HystrixCommandMetrics getInstance(HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixCommandProperties properties)
focal_class.identifier: getInstance
focal_class.modifiers: public static
focal_class.parameters: (HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixCommandProperties properties)
focal_class.return: HystrixCommandMetrics
focal_class.signature: HystrixCommandMetrics getInstance(HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixCommandProperties properties)
focal_class.class_method_signature: HystrixCommandMetrics.getInstance(HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties properties)
focal_class.full_signature: public static HystrixCommandMetrics getInstance(HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties properties)
focal_class.identifier: getInstance
focal_class.modifiers: public static
focal_class.parameters: (HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties properties)
focal_class.return: HystrixCommandMetrics
focal_class.signature: HystrixCommandMetrics getInstance(HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties properties)
focal_class.class_method_signature: HystrixCommandMetrics.getInstance(HystrixCommandKey key)
focal_class.full_signature: public static HystrixCommandMetrics getInstance(HystrixCommandKey key)
focal_class.identifier: getInstance
focal_class.modifiers: public static
focal_class.parameters: (HystrixCommandKey key)
focal_class.return: HystrixCommandMetrics
focal_class.signature: HystrixCommandMetrics getInstance(HystrixCommandKey key)
focal_class.class_method_signature: HystrixCommandMetrics.getInstances()
focal_class.full_signature: public static Collection<HystrixCommandMetrics> getInstances()
focal_class.identifier: getInstances
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: Collection<HystrixCommandMetrics>
focal_class.signature: Collection<HystrixCommandMetrics> getInstances()
focal_class.class_method_signature: HystrixCommandMetrics.reset()
focal_class.full_signature: static void reset()
focal_class.identifier: reset
focal_class.modifiers: static
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void reset()
focal_class.class_method_signature: HystrixCommandMetrics.HystrixCommandMetrics(final HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties properties, HystrixEventNotifier eventNotifier)
focal_class.full_signature:   HystrixCommandMetrics(final HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties properties, HystrixEventNotifier eventNotifier)
focal_class.identifier: HystrixCommandMetrics
focal_class.parameters: (final HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties properties, HystrixEventNotifier eventNotifier)
focal_class.signature:  HystrixCommandMetrics(final HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties properties, HystrixEventNotifier eventNotifier)
focal_class.class_method_signature: HystrixCommandMetrics.resetStream()
focal_class.full_signature: synchronized void resetStream()
focal_class.identifier: resetStream
focal_class.modifiers: synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void resetStream()
focal_class.class_method_signature: HystrixCommandMetrics.getCommandKey()
focal_class.full_signature: public HystrixCommandKey getCommandKey()
focal_class.identifier: getCommandKey
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: HystrixCommandKey
focal_class.signature: HystrixCommandKey getCommandKey()
focal_class.class_method_signature: HystrixCommandMetrics.getCommandGroup()
focal_class.full_signature: public HystrixCommandGroupKey getCommandGroup()
focal_class.identifier: getCommandGroup
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: HystrixCommandGroupKey
focal_class.signature: HystrixCommandGroupKey getCommandGroup()
focal_class.class_method_signature: HystrixCommandMetrics.getThreadPoolKey()
focal_class.full_signature: public HystrixThreadPoolKey getThreadPoolKey()
focal_class.identifier: getThreadPoolKey
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: HystrixThreadPoolKey
focal_class.signature: HystrixThreadPoolKey getThreadPoolKey()
focal_class.class_method_signature: HystrixCommandMetrics.getProperties()
focal_class.full_signature: public HystrixCommandProperties getProperties()
focal_class.identifier: getProperties
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: HystrixCommandProperties
focal_class.signature: HystrixCommandProperties getProperties()
focal_class.class_method_signature: HystrixCommandMetrics.getRollingCount(HystrixEventType eventType)
focal_class.full_signature: public long getRollingCount(HystrixEventType eventType)
focal_class.identifier: getRollingCount
focal_class.modifiers: public
focal_class.parameters: (HystrixEventType eventType)
focal_class.return: long
focal_class.signature: long getRollingCount(HystrixEventType eventType)
focal_class.class_method_signature: HystrixCommandMetrics.getCumulativeCount(HystrixEventType eventType)
focal_class.full_signature: public long getCumulativeCount(HystrixEventType eventType)
focal_class.identifier: getCumulativeCount
focal_class.modifiers: public
focal_class.parameters: (HystrixEventType eventType)
focal_class.return: long
focal_class.signature: long getCumulativeCount(HystrixEventType eventType)
focal_class.class_method_signature: HystrixCommandMetrics.getCumulativeCount(HystrixRollingNumberEvent event)
focal_class.full_signature: @Override public long getCumulativeCount(HystrixRollingNumberEvent event)
focal_class.identifier: getCumulativeCount
focal_class.modifiers: @Override public
focal_class.parameters: (HystrixRollingNumberEvent event)
focal_class.return: long
focal_class.signature: long getCumulativeCount(HystrixRollingNumberEvent event)
focal_class.class_method_signature: HystrixCommandMetrics.getRollingCount(HystrixRollingNumberEvent event)
focal_class.full_signature: @Override public long getRollingCount(HystrixRollingNumberEvent event)
focal_class.identifier: getRollingCount
focal_class.modifiers: @Override public
focal_class.parameters: (HystrixRollingNumberEvent event)
focal_class.return: long
focal_class.signature: long getRollingCount(HystrixRollingNumberEvent event)
focal_class.class_method_signature: HystrixCommandMetrics.getExecutionTimePercentile(double percentile)
focal_class.full_signature: public int getExecutionTimePercentile(double percentile)
focal_class.identifier: getExecutionTimePercentile
focal_class.modifiers: public
focal_class.parameters: (double percentile)
focal_class.return: int
focal_class.signature: int getExecutionTimePercentile(double percentile)
focal_class.class_method_signature: HystrixCommandMetrics.getExecutionTimeMean()
focal_class.full_signature: public int getExecutionTimeMean()
focal_class.identifier: getExecutionTimeMean
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getExecutionTimeMean()
focal_class.class_method_signature: HystrixCommandMetrics.getTotalTimePercentile(double percentile)
focal_class.full_signature: public int getTotalTimePercentile(double percentile)
focal_class.identifier: getTotalTimePercentile
focal_class.modifiers: public
focal_class.parameters: (double percentile)
focal_class.return: int
focal_class.signature: int getTotalTimePercentile(double percentile)
focal_class.class_method_signature: HystrixCommandMetrics.getTotalTimeMean()
focal_class.full_signature: public int getTotalTimeMean()
focal_class.identifier: getTotalTimeMean
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getTotalTimeMean()
focal_class.class_method_signature: HystrixCommandMetrics.getRollingMaxConcurrentExecutions()
focal_class.full_signature: public long getRollingMaxConcurrentExecutions()
focal_class.identifier: getRollingMaxConcurrentExecutions
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getRollingMaxConcurrentExecutions()
focal_class.class_method_signature: HystrixCommandMetrics.getCurrentConcurrentExecutionCount()
focal_class.full_signature: public int getCurrentConcurrentExecutionCount()
focal_class.identifier: getCurrentConcurrentExecutionCount
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getCurrentConcurrentExecutionCount()
focal_class.class_method_signature: HystrixCommandMetrics.markCommandStart(HystrixCommandKey commandKey, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy)
focal_class.full_signature:  void markCommandStart(HystrixCommandKey commandKey, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy)
focal_class.identifier: markCommandStart
focal_class.parameters: (HystrixCommandKey commandKey, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy)
focal_class.return: void
focal_class.signature: void markCommandStart(HystrixCommandKey commandKey, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy)
focal_class.class_method_signature: HystrixCommandMetrics.markCommandDone(ExecutionResult executionResult, HystrixCommandKey commandKey, HystrixThreadPoolKey threadPoolKey, boolean executionStarted)
focal_class.full_signature:  void markCommandDone(ExecutionResult executionResult, HystrixCommandKey commandKey, HystrixThreadPoolKey threadPoolKey, boolean executionStarted)
focal_class.identifier: markCommandDone
focal_class.parameters: (ExecutionResult executionResult, HystrixCommandKey commandKey, HystrixThreadPoolKey threadPoolKey, boolean executionStarted)
focal_class.return: void
focal_class.signature: void markCommandDone(ExecutionResult executionResult, HystrixCommandKey commandKey, HystrixThreadPoolKey threadPoolKey, boolean executionStarted)
focal_class.class_method_signature: HystrixCommandMetrics.getHealthCountsStream()
focal_class.full_signature:  HealthCountsStream getHealthCountsStream()
focal_class.identifier: getHealthCountsStream
focal_class.parameters: ()
focal_class.return: HealthCountsStream
focal_class.signature: HealthCountsStream getHealthCountsStream()
focal_class.class_method_signature: HystrixCommandMetrics.getHealthCounts()
focal_class.full_signature: public HealthCounts getHealthCounts()
focal_class.identifier: getHealthCounts
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: HealthCounts
focal_class.signature: HealthCounts getHealthCounts()
focal_class.class_method_signature: HystrixCommandMetrics.unsubscribeAll()
focal_class.full_signature: private void unsubscribeAll()
focal_class.identifier: unsubscribeAll
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void unsubscribeAll()
focal_class.superclass: extends HystrixMetrics
focal_method.body: public HealthCounts getHealthCounts() {
          return healthCountsStream.getLatest();
      }
focal_method.class_method_signature: HystrixCommandMetrics.getHealthCounts()
focal_method.full_signature: public HealthCounts getHealthCounts()
focal_method.identifier: getHealthCounts
focal_method.invocations: getLatest
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: HealthCounts
focal_method.signature: HealthCounts getHealthCounts()