helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.44k stars 562 forks source link

Response.whenSent() only works when called before Response.send() #8875

Closed alwaysthecritic closed 2 weeks ago

alwaysthecritic commented 3 weeks ago

Environment Details


Problem Description

This documentation page on Metrics (https://helidon.io/docs/latest/se/guides/metrics) has a Timer code sample, with respond.send() followed by response.whenSent(), but in my code, if I do it that way around, I get no data recorded in my Timer metric. If I swap the order and call response.whenSent() first, then it works.

So either the documentation that includes such examples needs to be updated, or the code needs to be changed to work either way around. Regardless the Javadoc for the whenSent() method should probably explicitly describe what works (only before, or before/after).