Skip to content

fix(storage:metrics): eagerly initialize meters with only topicType tag#493

Merged
juha-aiven merged 1 commit intomainfrom
jeqo/fix-regression-eager-metrics
Jan 22, 2026
Merged

fix(storage:metrics): eagerly initialize meters with only topicType tag#493
juha-aiven merged 1 commit intomainfrom
jeqo/fix-regression-eager-metrics

Conversation

@jeqo
Copy link
Contributor

@jeqo jeqo commented Jan 22, 2026

Restores the eager initialization logic for global metrics that was accidentally removed in aa045fb. Meters with only the topicType tag (e.g., diskless bytesIn/bytesOut) are broker-level metrics that should be registered immediately on construction, ensuring they are visible in monitoring systems from broker startup.

Adds tests to prevent future regressions by verifying metrics are registered in the Yammer registry immediately after construction.

Restores the eager initialization logic for global metrics that was
accidentally removed in aa045fb. Meters with only the topicType tag
(e.g., diskless bytesIn/bytesOut) are broker-level metrics that should
be registered immediately on construction, ensuring they are visible
in monitoring systems from broker startup.

Adds tests to prevent future regressions by verifying metrics are
registered in the Yammer registry immediately after construction.
@jeqo jeqo force-pushed the jeqo/fix-regression-eager-metrics branch from eb8f0f4 to 399bb62 Compare January 22, 2026 13:10
@jeqo jeqo requested a review from juha-aiven January 22, 2026 13:14
@jeqo jeqo marked this pull request as ready for review January 22, 2026 13:14
Copy link
Contributor

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

This PR fixes a regression where broker-level metrics with only the topicType tag were not being eagerly initialized, making them invisible in monitoring systems until traffic occurred. The fix centralizes the eager initialization logic in the MeterWrapper constructor to handle both tag-less metrics and metrics with only the topicType tag.

Changes:

  • Updated MeterWrapper constructor to eagerly initialize meters with only topicType tag in addition to tag-less meters
  • Removed redundant explicit meter() calls in BrokerTopicMetrics constructor since eager initialization now happens automatically
  • Added comprehensive tests to verify eager initialization and prevent future regressions

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
storage/src/main/java/org/apache/kafka/storage/log/metrics/BrokerTopicMetrics.java Centralized eager initialization logic in MeterWrapper constructor to handle metrics with only topicType tag, removed explicit meter() calls
storage/src/test/java/org/apache/kafka/storage/log/metrics/BrokerTopicMetricsTest.java Added three new tests verifying eager initialization of broker-level metrics and a helper method to check registry presence

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@juha-aiven juha-aiven left a comment

Choose a reason for hiding this comment

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

LGTM

@juha-aiven juha-aiven merged commit d336b0d into main Jan 22, 2026
8 checks passed
@juha-aiven juha-aiven deleted the jeqo/fix-regression-eager-metrics branch January 22, 2026 14:25
giuseppelillo pushed a commit that referenced this pull request Jan 27, 2026
…ag (#493)

Restores the eager initialization logic for global metrics that was
accidentally removed in aa045fb. Meters with only the topicType tag
(e.g., diskless bytesIn/bytesOut) are broker-level metrics that should
be registered immediately on construction, ensuring they are visible
in monitoring systems from broker startup.

Adds tests to prevent future regressions by verifying metrics are
registered in the Yammer registry immediately after construction.
giuseppelillo pushed a commit that referenced this pull request Jan 27, 2026
…ag (#493)

Restores the eager initialization logic for global metrics that was
accidentally removed in aa045fb. Meters with only the topicType tag
(e.g., diskless bytesIn/bytesOut) are broker-level metrics that should
be registered immediately on construction, ensuring they are visible
in monitoring systems from broker startup.

Adds tests to prevent future regressions by verifying metrics are
registered in the Yammer registry immediately after construction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants