Spring Cloud Stream and Micrometer problem with @Timed annotation on a function

83 views Asked by At

I am using Spring Cloud Stream with Spring Cloud Function there is this simple method that I have:

    @Transactional
    @Timed(value = "rrems_handle_test", percentiles = [0.5, 0.95, 0.99])
    @Bean
    fun handleTest() = fun(it: Message<String>): String {
     ...
    }

And my expectation was to get the associated metrics correctly but the problem is that metrics (count, time, quantiles) are increased only after the startup once, and remain the same even when you call the method several times.

I am using:

  • Spring boot 3
  • Spring cloud stream solace binder 4.0.0
1

There are 1 answers

0
Gary Russell On

The handleTest() method is only invoked once, it is used to create the bean.

Once the bean is created the function it returned is invoked for each message.

You need to delegate to another instrumented bean method from within your function.