mysql: move MySQL-only metrics into the MySQL sink package - #5866
Conversation
📝 WalkthroughWalkthroughThe change exports the keyspace label helper, moves MySQL-specific Prometheus metrics into ChangesMetrics Ownership Migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/sink/mysql/metrics_test.go`:
- Around line 49-50: Update the assertion after
DeleteDMLEventRowsAffectedMetrics(changefeedID) to expect a collected series
count of 1, reflecting that only the otherChangefeedID actual/insert series
remains.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a41bec11-9da2-4f38-aa6e-1f5803cbd320
📒 Files selected for processing (19)
downstreamadapter/sink/mysql/causality/conflict_detector.godownstreamadapter/sink/mysql/sink.gopkg/metrics/changefeed.gopkg/metrics/ddl.gopkg/metrics/dispatcher.gopkg/metrics/dynamic_stream.gopkg/metrics/init.gopkg/metrics/log_coordinator.gopkg/metrics/maintainer.gopkg/metrics/redo.gopkg/metrics/scheduler.gopkg/metrics/sink.gopkg/metrics/statistics.gopkg/sink/mysql/metrics.gopkg/sink/mysql/metrics_test.gopkg/sink/mysql/mysql_writer.gopkg/sink/mysql/mysql_writer_dml_exec.gopkg/sink/mysql/mysql_writer_for_active_active_sync_stats.goserver/metrics.go
|
/test all |
|
/test all |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hongyunyan, wk989898 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
@3AceShowHand: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: close #5867
Metrics that only apply to the MySQL sink were defined and registered in
pkg/metrics. Affected-row recording and cleanup were also part of the genericmetrics.Statisticstype, although the values come fromsql.Result.RowsAffected()in the MySQL writer. This split ownership across the generic metrics package and the MySQL sink.What is changed and how it works?
pkg/sink/mysql/metrics.go.mysql.Writerand cache each labeled counter handle soWithLabelValuesis called only on the first use.metrics.Statistics.mysql.InitMetrics.metrics.GetKeyspaceLabelfor legacy and next-generation label names.The Prometheus metric names, labels, help text, and histogram buckets are unchanged. The encoder group output-channel gauge is now populated as intended.
Check List
Tests
The following checks passed:
go test ./pkg/sink/mysql -run "^TestDMLEventRowsAffectedMetrics$" -count=1go test --tags=intest ./pkg/sink/mysql -run "^TestDMLEventRowsAffectedMetrics$" -count=1go test ./pkg/metrics -count=1go test ./downstreamadapter/sink/mysql/causality ./downstreamadapter/sink/mysql ./server -run "^$" -count=1Questions
Will it cause performance regression or break compatibility?
No performance regression is expected. The MySQL writer caches labeled affected-row counters instead of calling
WithLabelValuesfor every DML event.The Prometheus contract is unchanged. The Go collector variables move from
pkg/metricstopkg/sink/mysql, and all in-repository callers are updated.Do you need to update user documentation, design documentation or monitoring documentation?
No. Existing dashboards and Prometheus queries continue to use the same metric names and labels.
Release note
Summary by CodeRabbit
New Features
Bug Fixes
Refactor