Java Code Examples for com.netflix.hystrix.HystrixCommandMetrics#getInstance()
The following examples show how to use
com.netflix.hystrix.HystrixCommandMetrics#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CircutBreakerEvent.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
public CircutBreakerEvent(HystrixCommandKey commandKey, Type type) { super(type); HystrixCommandMetrics hystrixCommandMetrics = HystrixCommandMetrics.getInstance(commandKey); if (hystrixCommandMetrics != null) { if (hystrixCommandMetrics.getCommandGroup() instanceof CustomizeCommandGroupKey) { CustomizeCommandGroupKey customCommandGroupKey = (CustomizeCommandGroupKey) hystrixCommandMetrics.getCommandGroup(); this.microservice = customCommandGroupKey.getInstance().getMicroserviceName(); this.role = customCommandGroupKey.getInstance().getInvocationType().name(); this.schema = customCommandGroupKey.getInstance().getSchemaId(); this.operation = customCommandGroupKey.getInstance().getOperationName(); } this.currentTotalRequest = hystrixCommandMetrics.getHealthCounts().getTotalRequests(); this.currentErrorPercentage = hystrixCommandMetrics.getHealthCounts().getErrorCount(); this.currentErrorCount = hystrixCommandMetrics.getHealthCounts().getErrorPercentage(); this.requestVolumeThreshold = hystrixCommandMetrics.getProperties().circuitBreakerRequestVolumeThreshold().get(); this.sleepWindowInMilliseconds = hystrixCommandMetrics.getProperties().circuitBreakerSleepWindowInMilliseconds().get(); this.errorThresholdPercentage = hystrixCommandMetrics.getProperties().circuitBreakerErrorThresholdPercentage().get(); } }
Example 2
Source File: HystrixKafkaCircuitBreaker.java From nakadi with MIT License | 6 votes |
public HystrixKafkaCircuitBreaker(final String brokerId) { commandKey = HystrixCommandKey.Factory.asKey(brokerId); commandProperties = HystrixPropertiesFactory.getCommandProperties(commandKey, null); threadPoolKey = HystrixThreadPoolKey.Factory.asKey(brokerId); hystrixCommandMetrics = HystrixCommandMetrics.getInstance( commandKey, HYSTRIX_CMD_GROUP_KEY, threadPoolKey, commandProperties); circuitBreaker = HystrixCircuitBreaker.Factory.getInstance( commandKey, HYSTRIX_CMD_GROUP_KEY, commandProperties, hystrixCommandMetrics); concurrentExecutionCount = new AtomicInteger(); }
Example 3
Source File: CircuitBreakerCommand.java From msf4j with Apache License 2.0 | 6 votes |
private void printMetrics() { HystrixCommandMetrics metrics = HystrixCommandMetrics. getInstance(HystrixCommandKey.Factory.asKey(this.getClass().getSimpleName())); StringBuilder m = new StringBuilder(); if (metrics != null) { HystrixCommandMetrics.HealthCounts health = metrics.getHealthCounts(); m.append("Requests: ").append(health.getTotalRequests()).append(" "); m.append("Errors: ").append(health.getErrorCount()).append(" ("). append(health.getErrorPercentage()).append("%) "); m.append("Mean: ").append(metrics.getExecutionTimePercentile(50)).append(" "); m.append("75th: ").append(metrics.getExecutionTimePercentile(75)).append(" "); m.append("90th: ").append(metrics.getExecutionTimePercentile(90)).append(" "); m.append("99th: ").append(metrics.getExecutionTimePercentile(99)).append(" "); } System.out.println(m); }
Example 4
Source File: TestCircutBreakerEventNotifier.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Test public void testMarkEvent() { Mockito.when(commandKey.name()).thenReturn("Consumer.springmvc.springmvcHello.sayHi"); new Expectations(HystrixCommandMetrics.class) { { HystrixCommandMetrics.getInstance(commandKey); result = null; } }; circutBreakerEventNotifier.markEvent(HystrixEventType.SHORT_CIRCUITED, commandKey); Assert.assertEquals(1, taskList.size()); circutBreakerEventNotifier.markEvent(HystrixEventType.SUCCESS, commandKey); Assert.assertEquals(2, taskList.size()); }
Example 5
Source File: HystrixCommandFacadeTest.java From astrix with Apache License 2.0 | 5 votes |
private int getEventCountForCommand(HystrixRollingNumberEvent hystrixRollingNumberEvent) { HystrixFaultToleranceFactory faultTolerance = (HystrixFaultToleranceFactory) AstrixApplicationContext.class.cast(this.context).getInstance(BeanFaultToleranceFactorySpi.class); HystrixCommandKey commandKey = faultTolerance.getCommandKey(AstrixBeanKey.create(Ping.class)); HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey); int currentConcurrentExecutionCount = (int) metrics.getCumulativeCount(hystrixRollingNumberEvent); return currentConcurrentExecutionCount; }
Example 6
Source File: HystrixObservableCommandFacadeTest.java From astrix with Apache License 2.0 | 5 votes |
private int getEventCountForCommand(HystrixRollingNumberEvent hystrixRollingNumberEvent) { HystrixFaultToleranceFactory faultTolerance = (HystrixFaultToleranceFactory) AstrixApplicationContext.class.cast(this.context).getInstance(BeanFaultToleranceFactorySpi.class); HystrixCommandKey commandKey = faultTolerance.getCommandKey(AstrixBeanKey.create(Ping.class)); HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey); int currentConcurrentExecutionCount = (int) metrics.getCumulativeCount(hystrixRollingNumberEvent); return currentConcurrentExecutionCount; }
Example 7
Source File: HystrixFaulttoleranceIntegrationTest.java From astrix with Apache License 2.0 | 5 votes |
private int getEventCountForCommand(HystrixRollingNumberEvent hystrixRollingNumberEvent, HystrixCommandKey commandKey) { HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey); if (metrics == null) { return 0; } int currentConcurrentExecutionCount = (int) metrics.getCumulativeCount(hystrixRollingNumberEvent); return currentConcurrentExecutionCount; }