Enhance GetStatsCmd to include additional options for backlog statistics#1801
Merged
Conversation
- Added flags for precise backlog size, subscription backlog size, and earliest time in backlog. - Updated doGetStats function to accept new parameters and utilize them in the stats retrieval process. - Modified calls to GetPartitionedStats and GetStats to use the new options structure.
- Implemented tests for precise backlog, subscription backlog size, and earliest time in backlog. - Added tests for handling multiple flags and partitioned topic statistics. - Ensured that the output matches expected default statistics for various scenarios.
|
@freeznet:Thanks for your contribution. For this PR, do we need to update docs? |
- Removed shorthand flags for precise backlog, subscription backlog size, and earliest time in backlog. - Updated flag definitions to enhance readability and maintain consistency in the command structure.
…nitions - Ensured that test cases for GetPerPartitionStats reflect the latest command structure. - Verified that the output remains consistent with expected statistics for partitioned topics.
There was a problem hiding this comment.
Pull Request Overview
Enhance the stats command to support new backlog-related options and ensure both partitioned and non-partitioned topics can leverage them.
- Added three new flags (
--get-precise-backlog,--get-subscription-backlog-size,--get-earliest-time-in-backlog) and wired them throughdoGetStats - Updated calls to use
GetStatsWithOptionandGetPartitionedStatsWithOptionwith a newGetStatsOptionsstruct - Expanded test coverage by adding tests for each new flag and various flag combinations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/ctl/topic/stats.go | Declared new boolean flags and passed them into doGetStats, then updated the underlying admin calls to use option-based helpers |
| pkg/ctl/topic/stats_test.go | Added unit tests to exercise precise backlog, subscription backlog, earliest-time flags, partitioned and per-partition stats |
Comments suppressed due to low confidence (2)
pkg/ctl/topic/stats.go:146
- [nitpick] For consistency with the other flag-prefixed variables (
getPreciseBacklogandgetEarliestTimeInBacklog), consider renamingsubscriptionBacklogSizetogetSubscriptionBacklogSize.
var subscriptionBacklogSize bool
pkg/ctl/topic/stats_test.go:300
- [nitpick] This local variable
defaultStatsshadows the package-leveldefaultStats. Consider renaming it toexpectedStatsto avoid confusion.
defaultStats := utils.PartitionedTopicStats{
nlu90
approved these changes
Jun 30, 2025
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.
fix #1800
(If this PR fixes a github issue, please add
Fixes #<xyz>.)Fixes #
(or if this PR is one task of a github issue, please add
Master Issue: #<xyz>to link to the master issue.)Master Issue: #
Motivation
Explain here the context, and why you're making that change. What is the problem you're trying to solve.
Modifications
Describe the modifications you've done.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Documentation
Check the box below.
Need to update docs?
doc-required(If you need help on updating docs, create a doc issue)
no-need-doc(Please explain why)
doc(If this PR contains doc changes)