当前位置: 首页>>代码示例>>Java>>正文


Java HystrixCommandCompletionStream类代码示例

本文整理汇总了Java中com.netflix.hystrix.metric.HystrixCommandCompletionStream的典型用法代码示例。如果您正苦于以下问题:Java HystrixCommandCompletionStream类的具体用法?Java HystrixCommandCompletionStream怎么用?Java HystrixCommandCompletionStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HystrixCommandCompletionStream类属于com.netflix.hystrix.metric包,在下文中一共展示了HystrixCommandCompletionStream类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import com.netflix.hystrix.metric.HystrixCommandCompletionStream; //导入依赖的package包/类
@Override
public void initialize(HystrixCommandMetrics metrics) {
    if (filter.test(metrics)) {
        final HystrixCommandKey key = metrics.getCommandKey();
        log.debug("Aggregate stream for command {}", key.name());
        streams.onNext(HystrixCommandCompletionStream.getInstance(key).observe());
    }
}
 
开发者ID:ringcentral,项目名称:hystrix-addons,代码行数:9,代码来源:AggregatedHystrixCommandCompletionStream.java

示例2: initialize

import com.netflix.hystrix.metric.HystrixCommandCompletionStream; //导入依赖的package包/类
@Override
public void initialize() {
    Gauge.builder(NAME_HYSTRIX_CIRCUIT_BREAKER_OPEN, circuitBreaker, c -> c.isOpen() ? 1 : 0)
        .tags(tags).register(meterRegistry);

    HystrixCommandCompletionStream.getInstance(commandKey)
        .observe()
        .subscribe(hystrixCommandCompletion -> {
                /*
                 our assumptions about latency as returned by hystrixCommandCompletion:
                 # a latency of >= 0 indicates that this the execution occurred.
                 # a latency of == -1 indicates that the execution didn't occur (default in execution result)
                 # a latency of < -1 indicates some clock problems.
                 We will only count executions, and ignore non-executions with a value of -1.
                 Latencies of < -1 are ignored as they will decrement the counts, and Prometheus will
                 take this as a reset of the counter, therefore this should be avoided by all means.
                 */
            long totalLatency = hystrixCommandCompletion.getTotalLatency();
            if (totalLatency >= 0) {
                Timer.builder(NAME_HYSTRIX_LATENCY_TOTAL)
                    .tags(tags)
                    .register(meterRegistry)
                    .record(totalLatency, TimeUnit.MILLISECONDS);
            } else if (totalLatency < -1) {
                LOG.warn("received negative totalLatency, event not counted. " +
                        "This indicates a clock skew? {}",
                    hystrixCommandCompletion);
            }
            long executionLatency = hystrixCommandCompletion.getExecutionLatency();
            if (executionLatency >= 0) {
                Timer.builder(NAME_HYSTRIX_LATENCY_EXECUTION)
                    .tags(tags)
                    .register(meterRegistry)
                    .record(executionLatency, TimeUnit.MILLISECONDS);
            } else if (executionLatency < -1) {
                LOG.warn("received negative executionLatency, event not counted. " +
                        "This indicates a clock skew? {}",
                    hystrixCommandCompletion);
            }
            for (HystrixEventType hystrixEventType : HystrixEventType.values()) {
                int count = hystrixCommandCompletion.getEventCounts().getCount(hystrixEventType);
                if (count > 0) {
                    switch (hystrixEventType) {
                            /* this list is derived from {@link HystrixCommandMetrics.HealthCounts.plus} */
                        case FAILURE:
                        case TIMEOUT:
                        case THREAD_POOL_REJECTED:
                        case SEMAPHORE_REJECTED:
                            Counter.builder(NAME_HYSTRIX_ERRORS)
                                .tags(tags)
                                .register(meterRegistry)
                                .increment(count);
                        case SUCCESS:
                            Counter.builder(NAME_HYSTRIX_REQUESTS)
                                .tags(tags)
                                .register(meterRegistry)
                                .increment(count);

                            break;
                    }

                    if(executionEvents.contains(hystrixEventType)) {
                        getExecutionCounter(hystrixEventType).increment(count);
                    } else if(fallbackEvents.contains(hystrixEventType)){
                        getFallbackCounter(hystrixEventType).increment(count);
                    } else {
                        getOtherExecutionCounter(hystrixEventType).increment(count);
                    }
                }
            }
        });

    String threadPool = metrics.getThreadPoolKey().name();
    Gauge.builder(NAME_HYSTRIX_THREADPOOL_CONCURRENT_EXECUTION_CURRENT, metrics, HystrixCommandMetrics::getCurrentConcurrentExecutionCount)
        .tags(Tags.concat(tags, "threadpool", threadPool))
        .register(meterRegistry);
    Gauge.builder(NAME_HYSTRIX_THREADPOOL_CONCURRENT_EXECUTION_ROLLING_MAX, metrics, HystrixCommandMetrics::getRollingMaxConcurrentExecutions)
        .tags(Tags.concat(tags, "threadpool", threadPool))
        .register(meterRegistry);

}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:82,代码来源:MicrometerMetricsPublisherCommand.java


注:本文中的com.netflix.hystrix.metric.HystrixCommandCompletionStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。