micronaut-micrometer icon indicating copy to clipboard operation
micronaut-micrometer copied to clipboard

TimedInterceptor specifies order

Open lightbody opened this issue 2 years ago • 1 comments
trafficstars

Feature description

TimedInterceptor doesn't override getOrder and return a specific value, so it gets 0. The docs for Ordered claim "Defaults to zero (no order)", but from my reading of how things work, 0 just means it'll happen before all the defined phases in InterceptPhase.

That means, if you put @Timed and @Async on the same method, I think you end up timing the tiny of bit code that kicks off the async work and not the actual work, which is probably not what most people would expect.

My proposal: have it return InterceptPhase.TRACE.

lightbody avatar May 24 '23 06:05 lightbody

Might also be worth changing the comment on Ordered to not say "no order" to clarify that it only means no defined order relative to other 0 values, but it definitely will come before any InterceptPhase work :)

lightbody avatar May 24 '23 18:05 lightbody