Examples of HystrixCommandMetrics


Examples of com.netflix.hystrix.HystrixCommandMetrics

            } else {
                assertThat(result).isEqualTo(Optional.<String>absent());
            }
        }

        final HystrixCommandMetrics sleepCommandMetrics = new SleepCommand(DependencyKey.SLEEP).getCommandMetrics();
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.THREAD_POOL_REJECTED))
                .isEqualTo(4);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.TIMEOUT))
                .isEqualTo(0);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.FALLBACK_SUCCESS))
                .isEqualTo(4);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.SHORT_CIRCUITED))
                .isEqualTo(0);

        final HystrixThreadPoolProperties threadPoolProperties = new SleepCommand(DependencyKey.SLEEP).getThreadpoolProperties();
View Full Code Here

Examples of com.netflix.hystrix.HystrixCommandMetrics

            } else {
                assertThat(result).isEqualTo(Optional.<String>absent());
            }
        }

        final HystrixCommandMetrics sleepCommandMetrics = new SleepCommand(DependencyKey.EXAMPLE).getCommandMetrics();
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.THREAD_POOL_REJECTED))
                .isGreaterThan(15);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.TIMEOUT))
                .isEqualTo(0);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.FALLBACK_SUCCESS))
                .isGreaterThanOrEqualTo(40);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.FALLBACK_FAILURE))
                .isEqualTo(0);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.FALLBACK_REJECTION))
                .isEqualTo(0);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.SHORT_CIRCUITED))
                .isEqualTo(sleepCommandMetrics.getCumulativeCount(HystrixRollingNumberEvent.FALLBACK_SUCCESS) -
                           sleepCommandMetrics.getCumulativeCount(HystrixRollingNumberEvent.THREAD_POOL_REJECTED));

        final HystrixThreadPoolProperties threadPoolProperties = new SleepCommand(DependencyKey.EXAMPLE).getThreadpoolProperties();

        //-1 means no limit on the number of items in the queue, which uses the SynchronousBlockingQueue
        assertEquals(threadPoolProperties.maxQueueSize().get().intValue(), -1);
View Full Code Here

Examples of com.netflix.hystrix.HystrixCommandMetrics

        final TenacityFailingCommand tenacityFailingCommand = new TenacityFailingCommand();
        for (int i = 0; i < 500; i++) {
            new TenacityFailingCommand().execute();
        }

        final HystrixCommandMetrics sleepCommandMetrics = tenacityFailingCommand.getCommandMetrics();
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.TIMEOUT))
                .isEqualTo(0);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.FALLBACK_SUCCESS))
                .isEqualTo(500);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.SHORT_CIRCUITED))
                .isGreaterThan(50);
        assertFalse("Allow request should be false", tenacityFailingCommand.getCircuitBreaker().allowRequest());
        assertTrue("Circuit Breaker should be open", tenacityFailingCommand.isCircuitBreakerOpen());
    }
View Full Code Here

Examples of com.netflix.hystrix.HystrixCommandMetrics

            new TenacityFailingCommand().execute();
            assertTrue("Allow request should be true", tenacityFailingCommand.getCircuitBreaker().allowRequest());
            assertFalse("Circuit Breaker should not be open", tenacityFailingCommand.isCircuitBreakerOpen());
        }

        final HystrixCommandMetrics sleepCommandMetrics = tenacityFailingCommand.getCommandMetrics();
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.TIMEOUT))
                .isEqualTo(0);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.FALLBACK_SUCCESS))
                .isEqualTo(10);
        assertThat(sleepCommandMetrics
                .getCumulativeCount(HystrixRollingNumberEvent.SHORT_CIRCUITED))
                .isEqualTo(0);
        assertTrue("Allow request should be true", tenacityFailingCommand.getCircuitBreaker().allowRequest());
        assertFalse("Circuit Breaker should not be open", tenacityFailingCommand.isCircuitBreakerOpen());
    }
View Full Code Here

Examples of com.netflix.hystrix.HystrixCommandMetrics

                    } catch (Exception e) {
                        // ignore
                    }

                    // we are using default names so can use class.getSimpleName() to derive the keys
                    HystrixCommandMetrics creditCardMetrics = HystrixCommandMetrics.getInstance(HystrixCommandKey.Factory.asKey(CreditCardCommand.class.getSimpleName()));
                    HystrixCommandMetrics orderMetrics = HystrixCommandMetrics.getInstance(HystrixCommandKey.Factory.asKey(GetOrderCommand.class.getSimpleName()));
                    HystrixCommandMetrics userAccountMetrics = HystrixCommandMetrics.getInstance(HystrixCommandKey.Factory.asKey(GetUserAccountCommand.class.getSimpleName()));
                    HystrixCommandMetrics paymentInformationMetrics = HystrixCommandMetrics.getInstance(HystrixCommandKey.Factory.asKey(GetPaymentInformationCommand.class.getSimpleName()));

                    // print out metrics
                    StringBuilder out = new StringBuilder();
                    out.append("\n");
                    out.append("#####################################################################################").append("\n");
View Full Code Here

Examples of com.netflix.hystrix.HystrixCommandMetrics

   * 演示获取Hystrix的Metrics.
   */
  public MetricsMap getHystrixMetrics() {
    MetricsMap metricsMap = new MetricsMap();
    HystrixCommandKey key = HystrixCommandKey.Factory.asKey("GetUserCommand");
    HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(key);

    if (metrics != null) {
      HealthCounts counts = metrics.getHealthCounts();
      HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(key);

      metricsMap.put("circuitOpen", circuitBreaker.isOpen());
      metricsMap.put("totalRequest", counts.getTotalRequests());
      metricsMap.put("errorPercentage", counts.getErrorPercentage());
      metricsMap.put("success", metrics.getRollingCount(HystrixRollingNumberEvent.SUCCESS));
      metricsMap.put("timeout", metrics.getRollingCount(HystrixRollingNumberEvent.TIMEOUT));
      metricsMap.put("failure", metrics.getRollingCount(HystrixRollingNumberEvent.FAILURE));
      metricsMap.put("shortCircuited", metrics.getRollingCount(HystrixRollingNumberEvent.SHORT_CIRCUITED));
      metricsMap.put("threadPoolRejected",
          metrics.getRollingCount(HystrixRollingNumberEvent.THREAD_POOL_REJECTED));
      metricsMap.put("semaphoreRejected", metrics.getRollingCount(HystrixRollingNumberEvent.SEMAPHORE_REJECTED));
      metricsMap.put("latency50", metrics.getTotalTimePercentile(50));
      metricsMap.put("latency90", metrics.getTotalTimePercentile(90));
      metricsMap.put("latency100", metrics.getTotalTimePercentile(100));
    }

    return metricsMap;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.