Search code examples
spring-bootdropwizardmetricsmicroservices

How to override URL suffix for Hystrix metrics stream endpoint?


In our setup we have lots of Dropwizard services which are streaming their metrics to a Hystrix dashboard.

We are writing a new service in Spring Boot and would like the metrics stream to be on the same URL as the Dropwizard one, but I can't find out how to override the stream servlet's URL pattern.

I'm sure this is configurable somehow, any ideas?


Solution

  • Had to register a custom bean to override the hard coded value like this in the application class:

    @Bean
    public CustomHystrixStreamEndpoint customHystrixStreamEndpoint() {
        return new CustomHystrixStreamEndpoint();
    }
    

    and the create the custom wrapper class like this:

        public class CustomHystrixStreamEndpoint extends ServletWrappingEndpoint {
    
            public CustomHystrixStreamEndpoint() {
                super(HystrixMetricsStreamServlet.class, "customHystrixStream",
                      "/tenacity/hystrix.stream",
                      false, true);
            }
        }
    

    and then turn off the default one like this in the config file:

    hystrix.stream.endpoint.enabled: false
    

    FYI the default wrapper class is called HystrixStreamEndpoint