com.sap.cloud.yaas.servicesdk.springboot.hystrix.HystrixAutoConfiguration Maven / Gradle / Ivy
/*
* © 2017 SAP SE or an SAP affiliate company.
* All rights reserved.
* Please see http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and
* notices.
*/
package com.sap.cloud.yaas.servicesdk.springboot.hystrix;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Configures Hystrix, registers the {@link HystrixMetricsStreamServlet} if it is found on the class path.
*/
@Configuration
@ConditionalOnClass(HystrixMetricsStreamServlet.class)
@ConditionalOnWebApplication
public class HystrixAutoConfiguration
{
/**
* Factory method that registers an instance of the {@link HystrixMetricsStreamServlet} as a Servlet for requests to
* {@code /hystrix.stream}.
*
* @return The hystrixMetricsStreamServletRegistration bean.
*/
@Bean
public ServletRegistrationBean hystrixMetricsStreamServletRegistration()
{
return new ServletRegistrationBean(new HystrixMetricsStreamServlet(), "/hystrix.stream");
}
}