Spring Cloud入门教程-使用Hystrix Dashboard 监控熔断器的状态
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class HystrixDashboardConfiguration {
@Bean
public ServletRegistrationBean hystrixMetricsStreamServlet() {
ServletRegistrationBean registration = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
registration.addUrlMappings("/hystrix.stream");
registration.setName("HystrixMetricsStreamServlet");
return registration;
}
}
这段代码定义了一个配置类,在Spring Boot应用中注册了HystrixMetricsStreamServlet
,这是Hystrix Dashboard用来获取Hystrix的监控数据的servlet。通过addUrlMappings
方法,我们将这个servlet绑定到了/hystrix.stream
这个URL上,这样就可以通过访问这个URL来获取Hystrix的实时监控数据。
评论已关闭