Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1550: remove multiple isFiltered invocations #1552

Merged
merged 1 commit into from
Sep 15, 2023

Conversation

ppkarwasz
Copy link
Contributor

Async logger configs call isFiltered(LogEvent) multiple times. While this is not a problem per-se, it can cause a performance penalty if the filter is slow and creates problems to stateful filters.

This PR reduces the number of isFiltered(LogEvent) calls to one and closes #1550.

Remark: this PR changes the public API by increasing the visibility of LoggerConfig#processLogEvent to protected.

@ppkarwasz ppkarwasz added bug Incorrect, unexpected, or unintended behavior of existing code api Affects the public API labels Jul 12, 2023
@ppkarwasz ppkarwasz added this to the 2.20.1 milestone Jul 12, 2023
@ppkarwasz ppkarwasz requested a review from remkop July 12, 2023 16:41
Async logger configs call `isFiltered(LogEvent)` multiple times. While
this is not a problem per-se, it can cause a performance penalty if the
filter is slow and creates problems to stateful filters.
@ppkarwasz ppkarwasz merged commit 59f8819 into apache:2.x Sep 15, 2023
7 checks passed
jonatan-ivanov added a commit to micrometer-metrics/micrometer that referenced this pull request Oct 20, 2023
In case of async loggers, the MetricsFilter#filter method is/was called
multiple times. Because of this, a check was introduced in gh-2183
assuming that if the event has the isEndOfBatch flag set to true, that
is the last filter method call for that event.
Unfortunately, it turned out that this approach did not work, since it
did not just filter out the unwanted multiple calls on one event but it
also filtered out all the filter method calls on events that were not at
the end of the async batch. So Log4j2Metrics counted batches of events,
not the individual events.
Fortunately multiple filter invocations was fixed in Log4j2,
see apache/logging-log4j2#1550 and apache/logging-log4j2#1552.
Since now there will be only one filter method call,
the check introduced in gh-2183 can and should be removed (the call to
the filter method is before the isEndOfBatch flag is set so
the flag will always return false).

Closes gh-2176
See gh-2183
See gh-4253
jonatan-ivanov added a commit to micrometer-metrics/micrometer that referenced this pull request Oct 20, 2023
In case of async loggers, the MetricsFilter#filter method is/was called
multiple times. Because of this, a check was introduced in gh-2183
assuming that if the event has the isEndOfBatch flag set to true, that
is the last filter method call for that event.
Unfortunately, it turned out that this approach did not work, since it
did not just filter out the unwanted multiple calls on one event but it
also filtered out all the filter method calls on events that were not at
the end of the async batch. So Log4j2Metrics counted batches of events,
not the individual events.
Fortunately multiple filter invocations was fixed in Log4j2,
see apache/logging-log4j2#1550 and apache/logging-log4j2#1552.
Since now there will be only one filter method call,
the check introduced in gh-2183 can and should be removed (the call to
the filter method is before the isEndOfBatch flag is set so
the flag will always return false).

Closes gh-2176
See gh-2183
See gh-4253
jonatan-ivanov added a commit to micrometer-metrics/micrometer that referenced this pull request Oct 20, 2023
In case of async loggers, the MetricsFilter#filter method is/was called
multiple times. Because of this, a check was introduced in gh-2183
assuming that if the event has the isEndOfBatch flag set to true, that
is the last filter method call for that event.
Unfortunately, it turned out that this approach did not work, since it
did not just filter out the unwanted multiple calls on one event but it
also filtered out all the filter method calls on events that were not at
the end of the async batch. So Log4j2Metrics counted batches of events,
not the individual events.
Fortunately multiple filter invocations was fixed in Log4j2,
see apache/logging-log4j2#1550 and apache/logging-log4j2#1552.
Since now there will be only one filter method call,
the check introduced in gh-2183 can and should be removed (the call to
the filter method is before the isEndOfBatch flag is set so
the flag will always return false).

Closes gh-2176
See gh-2183
See gh-4253
jonatan-ivanov added a commit to micrometer-metrics/micrometer that referenced this pull request Oct 25, 2023
In case of async loggers, the MetricsFilter#filter method is/was called
multiple times. Because of this, a check was introduced in gh-2183
assuming that if the event has the isEndOfBatch flag set to true, that
is the last filter method call for that event.
Unfortunately, it turned out that this approach did not work, since it
did not just filter out the unwanted multiple calls on one event but it
also filtered out all the filter method calls on events that were not at
the end of the async batch. So Log4j2Metrics counted batches of events,
not the individual events.
Fortunately multiple filter invocations was fixed in Log4j2,
see apache/logging-log4j2#1550 and apache/logging-log4j2#1552.
Since now there will be only one filter method call,
the check introduced in gh-2183 can and should be removed (the call to
the filter method is before the isEndOfBatch flag is set so
the flag will always return false).

Closes gh-2176
See gh-2183
See gh-4253
jonatan-ivanov added a commit to micrometer-metrics/micrometer that referenced this pull request Oct 25, 2023
In case of async loggers, the MetricsFilter#filter method is/was called
multiple times. Because of this, a check was introduced in gh-2183
assuming that if the event has the isEndOfBatch flag set to true, that
is the last filter method call for that event.
Unfortunately, it turned out that this approach did not work, since it
did not just filter out the unwanted multiple calls on one event but it
also filtered out all the filter method calls on events that were not at
the end of the async batch. So Log4j2Metrics counted batches of events,
not the individual events.
Fortunately multiple filter invocations was fixed in Log4j2,
see apache/logging-log4j2#1550 and apache/logging-log4j2#1552.
Since now there will be only one filter method call,
the check introduced in gh-2183 can and should be removed (the call to
the filter method is before the isEndOfBatch flag is set so
the flag will always return false).

Closes gh-2176
See gh-2183
See gh-4253
@ppkarwasz ppkarwasz deleted the async-filter branch November 21, 2023 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Affects the public API bug Incorrect, unexpected, or unintended behavior of existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple filter invocations in AsyncLoggerConfig
1 participant