Skip to content

refactor: custom metrics configuration management#18312

Merged
parametalol merged 5 commits intomasterfrom
michael/custom-metrics-prefactoring
Feb 9, 2026
Merged

refactor: custom metrics configuration management#18312
parametalol merged 5 commits intomasterfrom
michael/custom-metrics-prefactoring

Conversation

@parametalol
Copy link
Contributor

@parametalol parametalol commented Dec 19, 2025

Description

A little hardening of the configuration management.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

CI.

@rhacs-bot
Copy link
Contributor

rhacs-bot commented Dec 19, 2025

Images are ready for the commit at f6c4cf9.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-65-gf6c4cf9925.

@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

❌ Patch coverage is 85.18519% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.47%. Comparing base (be77039) to head (f6c4cf9).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
central/metrics/custom/tracker/tracker_base.go 84.00% 1 Missing and 3 partials ⚠️
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     
Flag Coverage Δ
go-unit-tests 49.47% <85.18%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@parametalol parametalol changed the title refactor: prefactoring refactor: custom metrics configuration management Dec 23, 2025
@parametalol parametalol force-pushed the michael/custom-metrics-prefactoring branch 2 times, most recently from d913dfc to b6c3f0e Compare February 2, 2026 09:24
@parametalol parametalol requested a review from a team February 4, 2026 08:41
@parametalol parametalol force-pushed the michael/custom-metrics-prefactoring branch from dbcb8ee to f6c4cf9 Compare February 9, 2026 09:28
@parametalol parametalol merged commit 76d51d2 into master Feb 9, 2026
95 checks passed
@parametalol parametalol deleted the michael/custom-metrics-prefactoring branch February 9, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants