![JAR search and dependency download from the Maven repository](/logo.png)
com.netflix.hystrix.contrib.servopublisher.HystrixServoMetricsPublisher Maven / Gradle / Ivy
/**
* Copyright 2012 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.hystrix.contrib.servopublisher;
import com.netflix.hystrix.HystrixCircuitBreaker;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.HystrixCommandMetrics;
import com.netflix.hystrix.HystrixCommandProperties;
import com.netflix.hystrix.HystrixThreadPoolKey;
import com.netflix.hystrix.HystrixThreadPoolMetrics;
import com.netflix.hystrix.HystrixThreadPoolProperties;
import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisher;
import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherCommand;
import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherThreadPool;
/**
* Servo implementation of {@link HystrixMetricsPublisher}.
*
* See Wiki docs about plugins for more information.
*/
public class HystrixServoMetricsPublisher extends HystrixMetricsPublisher {
private static HystrixServoMetricsPublisher INSTANCE = null;
public static HystrixServoMetricsPublisher getInstance() {
if (INSTANCE == null) {
HystrixServoMetricsPublisher temp = createInstance();
INSTANCE = temp;
}
return INSTANCE;
}
private static synchronized HystrixServoMetricsPublisher createInstance() {
if (INSTANCE == null) {
return new HystrixServoMetricsPublisher();
} else {
return INSTANCE;
}
}
private HystrixServoMetricsPublisher() {
}
@Override
public HystrixMetricsPublisherCommand getMetricsPublisherForCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties) {
return new HystrixServoMetricsPublisherCommand(commandKey, commandGroupKey, metrics, circuitBreaker, properties);
}
@Override
public HystrixMetricsPublisherThreadPool getMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, HystrixThreadPoolProperties properties) {
return new HystrixServoMetricsPublisherThreadPool(threadPoolKey, metrics, properties);
}
}