quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.8k stars 2.68k forks source link

micrometer metrics support for logging the time #34620

Open debu999 opened 1 year ago

debu999 commented 1 year ago

Description

currently we have publish option to push the metrics. Is there any way we can also log each metrics capture for methods and execution time. This will help debug any botttlenecks in the system. Metrics support max/count/avg time for @timed. But if possible we can have a logger enabled so we can track them for debugging issues. We use custom logging for the application now.

micrometer

Implementation ideas

No response

quarkus-bot[bot] commented 1 year ago

/cc @brunobat (micrometer), @ebullient (metrics,micrometer), @jmartisk (metrics)

brunobat commented 1 year ago

You can access those timed metrics on the /q/metrics endpoint when using prometheus. This provides aggregated results. Having that logged per individual method having a @Timed annotation, probably per call, sounds more like OpenTelemetry Tracing.

debu999 commented 1 year ago

We have aspectj that can help do the same and we can have a pointcut to do the logging. Is there anything that we can do. I was reading interceptors but they work only for cdi's. Since @timed is a interceptor to track, just wanted to see how can we log. as all metrics interceptors are for aggregations

brunobat commented 1 year ago

If you want to add a log line with the duration of all the timed methods this can be done by creating a new interceptor of your own. I would't recommend doing this as it can potentially generate a lot of logging and OpenTelemetry Tracing can give you this and much more: https://quarkus.io/guides/opentelemetry