Skip to content

Conversation

@freeznet
Copy link
Member

@freeznet freeznet commented Jun 9, 2025

fix #1800

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

(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

  • Make sure that the change passes the CI checks.

(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:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

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)

freeznet added 2 commits June 9, 2025 15:09
- 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 freeznet self-assigned this Jun 9, 2025
@github-actions
Copy link

github-actions bot commented Jun 9, 2025

@freeznet:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions github-actions bot added the doc-info-missing This pr needs to mark a document option in description label Jun 9, 2025
freeznet added 2 commits June 9, 2025 15:41
- 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.
@freeznet freeznet requested a review from Copilot June 9, 2025 07:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 through doGetStats
  • Updated calls to use GetStatsWithOption and GetPartitionedStatsWithOption with a new GetStatsOptions struct
  • 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 (getPreciseBacklog and getEarliestTimeInBacklog), consider renaming subscriptionBacklogSize to getSubscriptionBacklogSize.
var subscriptionBacklogSize bool

pkg/ctl/topic/stats_test.go:300

  • [nitpick] This local variable defaultStats shadows the package-level defaultStats. Consider renaming it to expectedStats to avoid confusion.
defaultStats := utils.PartitionedTopicStats{

@freeznet freeznet merged commit bd9f0cb into master Jul 1, 2025
10 checks passed
@freeznet freeznet deleted the freeznet/topic-stats-additional-flags branch July 1, 2025 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-info-missing This pr needs to mark a document option in description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetStats support GetStatsOptions

3 participants