Skip to content

metrics: add redo metrics#4207

Draft
wk989898 wants to merge 2 commits intopingcap:masterfrom
wk989898:redo-metrics-0213
Draft

metrics: add redo metrics#4207
wk989898 wants to merge 2 commits intopingcap:masterfrom
wk989898:redo-metrics-0213

Conversation

@wk989898
Copy link
Collaborator

What problem does this PR solve?

Issue Number: ref #1061

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

If you don't think this PR needs a release note then fill it with `None`.

Signed-off-by: wk989898 <nhsmwk@gmail.com>
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 13, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 13, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 13, 2026

[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 assign wlwilliamx for approval. 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

Important

Review skipped

Draft detected.

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.

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
  • Post copyable unit tests in a comment

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 and usage tips.

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 13, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @wk989898, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the observability of the redo sink component by introducing a comprehensive set of new metrics. It centralizes metric collection within a dedicated structure, allowing for more granular tracking of redo log operations and worker performance. The changes also ensure that monitoring dashboards accurately reflect these new and refined metrics, providing better insights into the redo sink's behavior.

Highlights

  • New Redo Sink Metrics: Introduced a dedicated redoSinkMetrics struct to encapsulate and manage various metrics related to the redo sink, including write durations for rows and DDLs, total row and DDL counts, and worker busy ratios.
  • Metric Collection Refactoring: Refactored the Sink component to utilize the new redoSinkMetrics for observing DDL and DML write operations, replacing the previous generic statistics object.
  • Grafana Dashboard Updates: Updated existing Grafana dashboard configurations to align with the new metric names and corrected the calculation for the ticdc_redo_worker_busy_ratio metric.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • downstreamadapter/sink/redo/metrics.go
    • Added a new file defining the redoSinkMetrics struct and its associated methods for initializing, observing, and closing redo sink metrics.
  • downstreamadapter/sink/redo/sink.go
    • Removed the direct import of pkg/metrics as metric handling is now localized.
    • Replaced the statistics field with a metric field of type redoSinkMetrics in the Sink struct.
    • Initialized the new metric field in the New function.
    • Modified WriteBlockEvent to record DDL write duration using the new redoSinkMetrics.
    • Removed the statistics.RecordBatchExecution call from AddDMLEvent.
    • Updated the Close method to call the close method on the new redoSinkMetrics instance.
    • Modified sendMessages to record row write duration using the new redoSinkMetrics.
  • metrics/grafana/ticdc_new_arch.json
    • Updated the Prometheus expression for ticdc_redo_flushall_duration_seconds_bucket to ticdc_redo_flush_all_duration_seconds_bucket.
    • Corrected the calculation for ticdc_redo_worker_busy_ratio from division by 10 to multiplication by 100.
  • metrics/nextgengrafana/ticdc_new_arch_next_gen.json
    • Updated the Prometheus expression for ticdc_redo_flushall_duration_seconds_bucket to ticdc_redo_flush_all_duration_seconds_bucket.
    • Corrected the calculation for ticdc_redo_worker_busy_ratio from division by 10 to multiplication by 100.
  • pkg/metrics/redo.go
    • Added RedoTotalRowsCountGauge to track the total number of rows written to the redo log.
    • Added RedoWriteLogDurationHistogram to measure the latency of write log operations.
    • Added RedoWorkerBusyRatio to monitor the busy ratio of the redo sink worker.
    • Registered the newly introduced metrics in the initRedoMetrics function.
Activity
  • The pull request was opened by wk989898.
  • The pull request references issue Add redo support #1061, indicating a related problem or feature request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

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

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 new metrics for the redo log sink, replacing the generic statistics collector. The changes include adding new Prometheus metrics for redo log operations, integrating them into the redo sink, and updating Grafana dashboards to use these new metrics. My review focuses on the correctness of the new metrics implementation and potential regressions. I've identified a potential regression where batch-level metrics are no longer reported, and a couple of areas for improvement in the new metrics code.

return nil
}

func (s *Sink) AddDMLEvent(event *commonEvent.DMLEvent) {

Choose a reason for hiding this comment

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

high

By removing statistics.RecordBatchExecution, we've lost valuable batch-level metrics such as ExecBatchHistogram (batch size in rows) and ExecBatchWriteBytesHistogram (batch size in bytes). While new per-row metrics are added, these batch metrics are important for monitoring and performance tuning. Was this intentional? If not, please consider reintroducing them or providing an equivalent.

@@ -0,0 +1,82 @@
// Copyright 2026 PingCAP, Inc.

Choose a reason for hiding this comment

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

medium

The copyright year is set to 2026, which is in the future. Please correct it to the current year.

Suggested change
// Copyright 2026 PingCAP, Inc.
// Copyright 2024 PingCAP, Inc.

@wk989898 wk989898 mentioned this pull request Feb 14, 2026
7 tasks
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant