Skip to content

metrics: add keyspace ID label to changefeed metrics (#5662) - #5666

Merged
asddongmen merged 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-5662-to-release-nextgen-202603
Jul 18, 2026
Merged

asddongmen merged 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-5662-to-release-nextgen-202603

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #5662

What problem does this PR solve?

Issue Number: close #5661

Changefeed-level owner and sink metrics expose keyspace names but not the numeric keyspace ID, which makes correlation with PD/TiDB keyspace metadata difficult.

What is changed and how it works?

  • Add a decimal keyspace_id label to ticdc_owner_checkpoint_ts_lag, ticdc_owner_status, and ticdc_sink_batch_row_count_sum.
  • Read the owner label from ChangeFeedInfo.KeyspaceID.
  • Propagate the existing DispatcherManager.keyspaceID through sink constructors into metrics.Statistics; standalone consumers and redo applier use the default keyspace ID.
  • Delete metric series with the complete label set during changefeed or sink cleanup.
  • Keep ChangeFeedID, ChangeFeedDisplayName, protobuf messages, and persisted metadata unchanged.

The sink metric is a histogram, so its _bucket, _sum, and _count series all receive the label.

Check List

Tests

  • Unit test
  • Build test: make cdc

Questions

Will it cause performance regression or break compatibility?

No material performance regression is expected. The added label changes Prometheus series identity after upgrade, so dashboards and alerts that aggregate or match exact label sets may need adjustment.

Do you need to update user documentation, design documentation or monitoring documentation?

No repository documentation is changed. The metric compatibility impact is described above.

Release note

Add the `keyspace_id` label to changefeed owner status, checkpoint lag, and sink batch row count metrics.

Summary by CodeRabbit

  • Enhancements
    • Added keyspace-aware labeling to changefeed, checkpoint, and sink execution metrics.
    • Improved metric cleanup when changefeeds stop, including status and checkpoint metrics.
    • Propagated keyspace context across supported sink types for more accurate metric attribution.
  • Tests
    • Expanded coverage to verify keyspace labels and complete metric cleanup.

@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603 labels Jul 17, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member Author

@asddongmen This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot

ti-chi-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

Details

Instructions 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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 899bcbe1-a2da-431e-bc45-605e013fe41f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a keyspace ID label to various changefeed and sink metrics to improve observability. However, the changes contain numerous unresolved merge conflict markers across multiple files, including controller logic, sink implementations, and tests. These conflicts introduce critical compilation errors (such as undefined variables and re-declarations) and potential runtime panics due to mismatched label counts. All merge conflicts must be resolved, and the redundant or broken code blocks must be cleaned up before this PR can be merged.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread coordinator/controller.go Resolved
Comment thread coordinator/controller.go Resolved
Comment thread downstreamadapter/sink/kafka/sink.go Resolved
Comment thread downstreamadapter/sink/kafka/sink.go Resolved
Comment thread downstreamadapter/sink/mysql/sink.go Resolved
Comment thread coordinator/controller_test.go Resolved
@asddongmen
asddongmen force-pushed the cherry-pick-5662-to-release-nextgen-202603 branch from 934c452 to a1e0e7f Compare July 17, 2026 04:24
@ti-chi-bot

ti-chi-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from asddongmen. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot

Copy link
Copy Markdown
Member Author

Cherry-pick conflicts appear resolved; removing the do-not-merge/hold label.

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 17, 2026
@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 17, 2026
@asddongmen
asddongmen force-pushed the cherry-pick-5662-to-release-nextgen-202603 branch from a1e0e7f to b121cd3 Compare July 17, 2026 04:48
@asddongmen

Copy link
Copy Markdown
Collaborator

/test all

@ti-chi-bot

ti-chi-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

@asddongmen: No jobs can be run with /test all.
The following commands are available to trigger optional jobs:

/test pull-build-next-gen
/test pull-cdc-kafka-integration-heavy-next-gen
/test pull-cdc-kafka-integration-heavy-next-gen-legacy-safepoint
/test pull-cdc-kafka-integration-light-next-gen
/test pull-cdc-kafka-integration-light-next-gen-legacy-safepoint
/test pull-cdc-mysql-integration-heavy-next-gen
/test pull-cdc-mysql-integration-heavy-next-gen-legacy-safepoint
/test pull-cdc-mysql-integration-light-next-gen
/test pull-cdc-mysql-integration-light-next-gen-legacy-safepoint
/test pull-cdc-pulsar-integration-heavy-next-gen
/test pull-cdc-pulsar-integration-heavy-next-gen-legacy-safepoint
/test pull-cdc-pulsar-integration-light-next-gen
/test pull-cdc-pulsar-integration-light-next-gen-legacy-safepoint
/test pull-cdc-storage-integration-heavy-next-gen
/test pull-cdc-storage-integration-heavy-next-gen-legacy-safepoint
/test pull-cdc-storage-integration-light-next-gen
/test pull-cdc-storage-integration-light-next-gen-legacy-safepoint
/test pull-unit-test-next-gen
Details

In response to this:

/test all

Instructions 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.

@tenfyzhong

Copy link
Copy Markdown
Contributor

/test next-gen

Comment thread coordinator/changefeed/changefeed_db.go Resolved
@asddongmen

Copy link
Copy Markdown
Collaborator

/test next-gen

@asddongmen

Copy link
Copy Markdown
Collaborator

/test pull-cdc-kafka-integration-light-next-gen
/test pull-cdc-mysql-integration-heavy-next-gen

@asddongmen
asddongmen merged commit 69c10e6 into pingcap:release-nextgen-202603 Jul 18, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants