本文整理汇总了Java中com.netflix.hystrix.HystrixCommandMetrics.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java HystrixCommandMetrics.getInstance方法的具体用法?Java HystrixCommandMetrics.getInstance怎么用?Java HystrixCommandMetrics.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.hystrix.HystrixCommandMetrics
的用法示例。
在下文中一共展示了HystrixCommandMetrics.getInstance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HystrixKafkaCircuitBreaker
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
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();
}
示例2: printMetrics
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
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);
}
示例3: getHystrixTotalTimeMean
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public int getHystrixTotalTimeMean() {
HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
if (metrics != null) {
return metrics.getTotalTimeMean();
}
return 0;
}
示例4: getHystrixExecutionTimeMean
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public int getHystrixExecutionTimeMean() {
HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
if (metrics != null) {
return metrics.getExecutionTimeMean();
}
return 0;
}
示例5: getHystrixCurrentConcurrentExecutionCount
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public int getHystrixCurrentConcurrentExecutionCount() {
HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
if (metrics != null) {
return metrics.getCurrentConcurrentExecutionCount();
}
return 0;
}
示例6: getHystrixTotalRequests
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public long getHystrixTotalRequests() {
HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
if (metrics != null) {
return metrics.getHealthCounts().getTotalRequests();
}
return 0;
}
示例7: getHystrixErrorCount
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public long getHystrixErrorCount() {
HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
if (metrics != null) {
return metrics.getHealthCounts().getErrorCount();
}
return 0;
}
示例8: getHystrixErrorPercentage
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public int getHystrixErrorPercentage() {
HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
if (metrics != null) {
return metrics.getHealthCounts().getErrorPercentage();
}
return 0;
}
示例9: something
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@Scheduled(fixedRate = 1000)
public void something() {
final HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(HystrixCommandKey.Factory.asKey("request"));
if (metrics != null) { // metrics will be null until command is first used
LOGGER.info("command [{}]: execTime [{}] errors [{}]/[{}]", metrics.getCommandKey().name(),
metrics.getExecutionTimeMean(),
metrics.getHealthCounts().getErrorCount(),
metrics.getHealthCounts().getTotalRequests());
}
}
示例10: getEventCountForCommand
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
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;
}
示例11: getEventCountForCommand
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
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;
}
示例12: should_gather_json_metrics
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@Test
public void should_gather_json_metrics() throws Exception {
HystrixCommandKey hystrixCommandKey = HystrixCommandKey.Factory.asKey("commandKey");
HystrixCommandMetrics.getInstance(hystrixCommandKey,
HystrixCommandGroupKey.Factory.asKey("commandGroupKey"),
new HystrixPropertiesCommandDefault(hystrixCommandKey, HystrixCommandProperties.defaultSetter()));
this.hystrixStreamTask.setApplicationContext(this.context);
this.hystrixStreamTask.gatherMetrics();
assertThat(this.hystrixStreamTask.jsonMetrics.isEmpty(), is(false));
}
示例13: doCheck
import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@Override
public HealthCheckResult doCheck()
{
//
// Lookup the command group using the provided key. These may be null if
// no ApiCommands have been created and executed so no need to panic.
//
try
{
HystrixCommandKey cmdKey = HystrixCommandKey.Factory.asKey(key);
if (cmdKey == null)
{
return new HealthCheckResult(Status.HEALTHY);
}
HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(cmdKey);
if (metrics == null)
{
return new HealthCheckResult(Status.HEALTHY);
}
//
// As this point we should have viable metrics.
//
int windowSize = metrics.getProperties().metricsRollingStatisticalWindowInMilliseconds().get() / 1000;
long failCount = metrics.getRollingCount(HystrixRollingNumberEvent.FAILURE);
if (failCount >= minNumFailures)
{
return new HealthCheckResult(Status.UNHEALTHY, "Command has " + failCount + " failures in last " + windowSize + " seconds");
}
else
{
return new HealthCheckResult(Status.HEALTHY);
}
}
catch (Exception e)
{
return new HealthCheckResult(Status.UNKNOWN, "Could not get Hystrix metrics for command key " + key + ": " + e.getMessage());
}
}