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
RequestContextExportingAppender
has a dependency on Flags
which partially breaks logging
#5327
Comments
I haven't been able to analyze the issue in detail, but perhaps we can consider a lazy loading mechanism for each flag value. We have already had multiple issues stemming from cyclic dependency when the boolean VERBOSE_SOCKET_EXCEPTIONS to
The downside would be we won't be able to print flag values on initialization. Perhaps we can display this information somewhere else (i.e. |
I tried to make a simple reproducer but failed. It was tricky to align the initialization of the order of Flags and I guess we can keep logging events in |
I've created a branch for If you run it as is, you'll only see 3 logs from
If the line
|
Many thanks for the reproducer. 🙇♂️ |
|
…estContextExportingAppender` Motivation: If `Flags` class is initialized before `RequestContextExportingAppender` is registered to the root logger, the logs produced `Flags` during the initialization phase are siliently ignored. See line#5327 for the detail. Modifications: - Lasily create `RequestContextExporterBuilder` so as not to initialize `Flags` while ` RequestContextExportingAppender` is being initialized. - `RequestContextExporterBuilder` is created when `FlagsLoaded.get()` is true. Result: - `Flags` now correcly logs all message when `RequestContextExportingAppender` is configured. - Fixes line#5327
…estContextExportingAppender` (#5361) Motivation: If `Flags` class is initialized before `RequestContextExportingAppender` is registered to the root logger, the logs produced `Flags` in the initialization of the class are silently ignored. See #5327 for the details. Modifications: - Lazily create `RequestContextExporterBuilder` to not initialize `Flags` while ` RequestContextExportingAppender` is being initialized. - `RequestContextExporterBuilder` is created when `FlagsLoaded.get()` is true. Result: - `Flags` now correctly logs all messages when `RequestContextExportingAppender` is configured. - Fixes #5327
When Armeria is configured with Logback and
RequestContextExportingAppender
with custom headers, and when multiple Netty versions are present in the classpath, logs forFlags
will be missing.When the following appender with a custom header is configured in Logback:
The Logback setup flow will behave as follows:
setExport()
is called forreq.headers.x-real-ip
ExportGroupBuilder.requestHeader()
toHeaderName()
, we reach this call toFlags.validateHeaders()
Flags
class, which initializesTransportType
, which initializesTransportTypeProvider
Flags
will log the values of all flags, andTransportTypeProvider
will validate Netty versions and log a warning in case of inconsistenciesHowever, since we're still setting up Logback, no appenders are configured on
ROOT
level, so this information will never be logged.By removing
<export>req.headers.x-real-ip</export>
or usingreq.headers.user-agent
(a known and pre-cached header), the call toFlags.validateHeaders()
never happens, and theFlags
class is initialized after Logback setup is done. In that case, the logs will appear as expected.We can probably fix this by breaking the dependency between
RequestContextExportingAppender
and `Flags.The text was updated successfully, but these errors were encountered: