3
votes

For Spring Framework 5.0.1.RELEASE and Spring Boot 2.0.0.M6 We want to use the micrometer application monitoring, so wie included:

compile('org.springframework.boot:spring-boot-starter-actuator')
compile('io.micrometer:micrometer-registry-prometheus')

Into our dependency set and create a controller with the following rest endpoints:

@RestController
@Timed
public class MyController {

    @Autowired
    private MyService service;

    @RequestMapping(value = "/test", method = RequestMethod.GET)
    public void test() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @RequestMapping(value = "/test/flux", method = RequestMethod.GET, produces = "application/stream+json")
    public Flux<MyItem> getMyItems(@RequestParam Map<String, String> params) {
        return this.service.getMyItems(params);
    }
}

So we got the /test endpoint which is just waiting two seconds and we got the /test/flux endpoint which is returning a list of itmes.

Bot requests work. The only difference is that for the /test endpoint I get prometheus metrics and for the /test/flux endpoint I do not get any metrics:

http_server_requests_duration_seconds_count{exception="None",method="GET",status="200",uri="/get/test",} 1.0
http_server_requests_duration_seconds_sum{exception="None",method="GET",status="200",uri="/get/test",} 2.002811046
http_server_requests_duration_seconds_max{exception="None",method="GET",status="200",uri="/get/test",} 0.0

Do I have to configure something else to get that working for requests which are returning a Flux or is Flux yet not supported?

1
I believe that the webflux metrics are still being completed in micrometer. Follow this issue for details: github.com/micrometer-metrics/micrometer/issues/199checketts

1 Answers

2
votes

Autoconfiguration of WebFlux endpoints is included in Boot 2 RC2!