【发布时间】:2016-03-30 11:17:07
【问题描述】:
在我们的设置中,我们有许多 dropwizard 服务,它们将它们的指标流式传输到 hystrix 仪表板。
我们正在 Spring Boot 中编写一项新服务,并希望指标流与 dropwizard 位于同一 url,但我不知道如何覆盖流 servlet 的 url 模式。
我确定这是可以配置的,有什么想法吗?
【问题讨论】:
标签: spring-boot dropwizard metrics microservices
在我们的设置中,我们有许多 dropwizard 服务,它们将它们的指标流式传输到 hystrix 仪表板。
我们正在 Spring Boot 中编写一项新服务,并希望指标流与 dropwizard 位于同一 url,但我不知道如何覆盖流 servlet 的 url 模式。
我确定这是可以配置的,有什么想法吗?
【问题讨论】:
标签: spring-boot dropwizard metrics microservices
必须注册一个自定义 bean 来覆盖应用程序类中这样的硬编码值:
@Bean
public CustomHystrixStreamEndpoint customHystrixStreamEndpoint() {
return new CustomHystrixStreamEndpoint();
}
然后像这样创建自定义包装类:
public class CustomHystrixStreamEndpoint extends ServletWrappingEndpoint {
public CustomHystrixStreamEndpoint() {
super(HystrixMetricsStreamServlet.class, "customHystrixStream",
"/tenacity/hystrix.stream",
false, true);
}
}
然后在配置文件中像这样关闭默认的:
hystrix.stream.endpoint.enabled: false
仅供参考,默认包装类称为 HystrixStreamEndpoint
【讨论】: