【问题标题】:How to override url suffix for hystrix metrics stream endpoint?如何覆盖 hystrix 指标流端点的 url 后缀?
【发布时间】:2016-03-30 11:17:07
【问题描述】:

在我们的设置中,我们有许多 dropwizard 服务,它们将它们的指标流式传输到 hystrix 仪表板。

我们正在 Spring Boot 中编写一项新服务,并希望指标流与 dropwizard 位于同一 url,但我不知道如何覆盖流 servlet 的 url 模式。

我确定这是可以配置的,有什么想法吗?

【问题讨论】:

    标签: spring-boot dropwizard metrics microservices


    【解决方案1】:

    必须注册一个自定义 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

    【讨论】:

      猜你喜欢
      • 2021-10-30
      • 2018-11-16
      • 2021-11-10
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 2016-08-07
      相关资源
      最近更新 更多