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

Add logback logger context listener that re-adds MetricTurboFilters after logger context reset #2029

Merged

Conversation

bendiscz
Copy link
Contributor

The LogbackMetrics stops to record logback events after logback LoggerContext reset. The reset can happen for instance when a configuration is reloaded via the "scan" feature. The reset listener solves this issue by re-adding all metrics turbo filters after every reset.

Note that the metricsTurboFilters map was changed from a ConcurrentHashMap to a HashMap with synchronized blocks. This is to prevent a race-condition between a call to bindTo method and logback reset event.

Fixes #2028

Copy link
Member

@shakuzen shakuzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix. We'll want to rebase this onto 1.1.x so we can merge it into there and forward from there to later maintenance branches and master.
Also, is the issue this fixes something we could easily reproduce in a unit test? If so, it'd be good to have a test for it.

@bendiscz
Copy link
Contributor Author

You are right, this should be covered by a unit test, working on it right now.

Add logback logger context listener that re-adds MetricTurboFilters
after logger context reset (for instance when logback reloads its
configuration).
@bendiscz bendiscz force-pushed the logback_metrics_reset_listener branch from a411509 to 1859b6b Compare April 27, 2020 07:25
@bendiscz bendiscz changed the base branch from master to 1.1.x April 27, 2020 07:25
@shakuzen shakuzen merged commit f5406ac into micrometer-metrics:1.1.x Apr 27, 2020
@bendiscz bendiscz deleted the logback_metrics_reset_listener branch April 27, 2020 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LogbackMetrics stop to count logback events after LoggerContext reset
2 participants