码迷,mamicode.com
首页 > 其他好文 > 详细

hystrix源码小贴士之Yammer Publisher

时间:2018-01-04 13:07:46      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:shard   adp   veth   log   lap   ted   blog   reg   latency   

HystrixYammerMetricsPublisher

  继承HystrixMetricsPublisher,创建HystrixYammerMetricsPublisherCommand、HystrixYammerMetricsPublisherThreadPool、HystrixYammerMetricsPublisherCollapser。

 @Override
    public HystrixMetricsPublisherCommand getMetricsPublisherForCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties) {
        return new HystrixYammerMetricsPublisherCommand(commandKey, commandGroupKey, metrics, circuitBreaker, properties, metricsRegistry);
    }

    @Override
    public HystrixMetricsPublisherThreadPool getMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, HystrixThreadPoolProperties properties) {
        return new HystrixYammerMetricsPublisherThreadPool(threadPoolKey, metrics, properties, metricsRegistry);
    }

    @Override
    public HystrixMetricsPublisherCollapser getMetricsPublisherForCollapser(HystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, HystrixCollapserProperties properties) {
        return new HystrixYammerMetricsPublisherCollapser(collapserKey, metrics, properties, metricsRegistry);
    }

 HystrixYammerMetricsPublisherCommand

  从HystrixCommandMetrics获取数据,然后设置到MetricsRegistry中。

例如:

protected void createExecutionLatencyPercentileGauge(final String name, final double percentile) {
        metricsRegistry.newGauge(createMetricName(name), new Gauge<Integer>() {
            @Override
            public Integer value() {
                return metrics.getExecutionTimePercentile(percentile);
            }
        });
    }

 HystrixYammerMetricsPublisherThreadPool

  从HystrixThreadPoolMetrics获取数据,然后设置到MetricsRegistry中。

例如:

metricsRegistry.newGauge(createMetricName("rollingMaxActiveThreads"), new Gauge<Number>() {
            @Override
            public Number value() {
                return metrics.getRollingMaxActiveThreads();
            }
        });

HystrixYammerMetricsPublisherCollapser

  从HystrixCollapserMetrics获取数据,然后设置到MetricsRegistry中。

例如:

metricsRegistry.newGauge(createMetricName("shardSize_percentile_50"), new Gauge<Integer>() {
            @Override
            public Integer value() {
                return metrics.getShardSizePercentile(50);
            }
        });

 

hystrix源码小贴士之Yammer Publisher

标签:shard   adp   veth   log   lap   ted   blog   reg   latency   

原文地址:https://www.cnblogs.com/zhangwanhua/p/8192231.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!