You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
io.micrometer.core.instrument.binder.logging.Log4j2Metrics reports inaccurate metrics in case of async appender.
The decision to increment the counter is done by method :-
@Override
public Result filter(LogEvent event) {
if (!isAsyncLogger || isAsyncLoggerAndEndOfBatch(event)) {
incrementCounter(event); // always increments the counter by 1
}
return Result.NEUTRAL;
}
When isAsyncLoggerAndEndOfBatch(event) is true, counter should get incremented by "batch" size. (Not sure if its possible to get it from LogEvent parameter.
Environment
PROD
Micrometer version : 1.11.1
Micrometer registry : Any. I tried with AzureMetricRegistry and SimpleRegistry
OS: Linux
Java version: 17
To Reproduce
How to reproduce the bug:
Unzip and run attached Spring Boot application. It prints 2000 error level logs in burst every 30 secs.
Counter can be accessed using http://localhost:8080/actuator/metrics/log4j2.events
Repeat again with sync appender by change <AsyncRoot> to simply <Root> in log4j2.xml. This time counter value will be correct this time.
Expected behavior
Counter should report accurate metrics in case of async appender
If the fix for #2176 will also cover case when counter is increment by the "batch size" instead just 1, we can keep this one closed. In the end we just want accurate count anyways.
io.micrometer.core.instrument.binder.logging.Log4j2Metrics reports inaccurate metrics in case of async appender.
The decision to increment the counter is done by method :-
When
isAsyncLoggerAndEndOfBatch(event)
is true, counter should get incremented by "batch" size. (Not sure if its possible to get it fromLogEvent
parameter.Environment
PROD
To Reproduce
How to reproduce the bug:
Unzip and run attached Spring Boot application. It prints 2000 error level logs in burst every 30 secs.
Counter can be accessed using http://localhost:8080/actuator/metrics/log4j2.events
Repeat again with sync appender by change
<AsyncRoot>
to simply<Root>
inlog4j2.xml
. This time counter value will be correct this time.Expected behavior
Counter should report accurate metrics in case of async appender
Additional context
https://stackoverflow.com/questions/76660558/log4j2-metrics-with-micrometer
Archive.zip
The text was updated successfully, but these errors were encountered: