|
| 1 | +/** |
| 2 | + * Copyright 2012 Netflix, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.netflix.hystrix.contrib.servopublisher; |
| 17 | + |
| 18 | +import com.netflix.hystrix.HystrixCircuitBreaker; |
| 19 | +import com.netflix.hystrix.HystrixCommandGroupKey; |
| 20 | +import com.netflix.hystrix.HystrixCommandKey; |
| 21 | +import com.netflix.hystrix.HystrixCommandMetrics; |
| 22 | +import com.netflix.hystrix.HystrixCommandProperties; |
| 23 | +import com.netflix.hystrix.HystrixThreadPoolKey; |
| 24 | +import com.netflix.hystrix.HystrixThreadPoolMetrics; |
| 25 | +import com.netflix.hystrix.HystrixThreadPoolProperties; |
| 26 | +import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisher; |
| 27 | +import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherCommand; |
| 28 | +import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherThreadPool; |
| 29 | + |
| 30 | +/** |
| 31 | + * Servo implementation of {@link HystrixMetricsPublisher}. |
| 32 | + * <p> |
| 33 | + * See <a href="https://github.com/Netflix/Hystrix/wiki/Plugins">Wiki docs</a> about plugins for more information. |
| 34 | + */ |
| 35 | +public class HystrixServoMetricsPublisher extends HystrixMetricsPublisher { |
| 36 | + |
| 37 | + private static HystrixServoMetricsPublisher INSTANCE = new HystrixServoMetricsPublisher(); |
| 38 | + |
| 39 | + public static HystrixServoMetricsPublisher getInstance() { |
| 40 | + return INSTANCE; |
| 41 | + } |
| 42 | + |
| 43 | + private HystrixServoMetricsPublisher() { |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + public HystrixMetricsPublisherCommand getMetricsPublisherForCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties) { |
| 48 | + return new HystrixServoMetricsPublisherCommand(commandKey, commandGroupKey, metrics, circuitBreaker, properties); |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public HystrixMetricsPublisherThreadPool getMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, HystrixThreadPoolProperties properties) { |
| 53 | + return new HystrixServoMetricsPublisherThreadPool(threadPoolKey, metrics, properties); |
| 54 | + } |
| 55 | + |
| 56 | +} |
0 commit comments