refactor: custom metrics configuration management#18312
Merged
parametalol merged 5 commits intomasterfrom Feb 9, 2026
Merged
Conversation
Contributor
|
Images are ready for the commit at f6c4cf9. To use with deploy scripts, first |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #18312 +/- ##
==========================================
- Coverage 49.48% 49.47% -0.01%
==========================================
Files 2661 2661
Lines 200784 200782 -2
==========================================
- Hits 99351 99346 -5
- Misses 94016 94018 +2
- Partials 7417 7418 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `central/metrics/custom/tracker/tracker_base.go:137-143` </location>
<code_context>
}
- previous := tracker.setConfiguration(cfg)
+
+ tracker.metricsConfigMux.Lock()
+ defer tracker.metricsConfigMux.Unlock()
+ previous := tracker.config
+ tracker.config = cfg
+
if previous != nil {
- if cfg.period == 0 {
+ if !tracker.isEnabledNoLock() {
log.Debugf("Metrics collection has been disabled for %s", tracker.description)
tracker.unregisterMetrics(slices.Collect(maps.Keys(previous.metrics)))
</code_context>
<issue_to_address>
**issue (bug_risk):** Avoid holding metricsConfigMux while performing potentially heavy unregisterMetrics work
With the new `defer tracker.metricsConfigMux.Unlock()`, `unregisterMetrics` now runs while `metricsConfigMux` is held, whereas previously it executed after the lock was released. If `unregisterMetrics` is expensive or calls code that (directly or indirectly) takes this mutex, this can cause high contention or deadlocks. Please narrow the critical section to just updating/reading `tracker.config` (e.g., compute `previous` and whether metrics are disabled under the lock, then release it before calling `unregisterMetrics`).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This was referenced Dec 22, 2025
This was referenced Dec 23, 2025
d913dfc to
b6c3f0e
Compare
janisz
approved these changes
Feb 5, 2026
janisz
reviewed
Feb 5, 2026
dbcb8ee to
f6c4cf9
Compare
janisz
approved these changes
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A little hardening of the configuration management.
User-facing documentation
Testing and quality
Automated testing
How I validated my change
CI.