Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- public class MetricsConfiguration {
- /**
- * Register the metricsController.
- * @return Returns the ServletWrappingController for the Prometheus
- * MetricsServlet.
- */
- @Bean
- public ServletWrappingController metricsController() throws Exception {
- ServletWrappingController controller = new ServletWrappingController();
- controller.setServletClass(MetricsServlet.class);
- controller.setBeanName("metricsController");
- controller.afterPropertiesSet();
- return controller;
- }
- /**
- * Map /metrics to the metricsController.
- * @return Returns the SimpleUrlHandlerMapping.
- */
- @Bean
- public SimpleUrlHandlerMapping metricsControllerMapping() {
- SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
- Properties urlProperties = new Properties();
- urlProperties.put("/metrics", "metricsController");
- mapping.setMappings(urlProperties);
- mapping.setOrder(Integer.MAX_VALUE - 2);
- return mapping;
- }
- }
Add Comment
Please, Sign In to add comment