Repository navigation
[improve][broker] Implemets PIP-487: add event count metrics for InflightReadsLimiter acquire and release operations - #26093
Merged
poorbarcode merged 2 commits intoJul 15, 2026
Conversation
gaoran10
approved these changes
Jul 15, 2026
Technoboy-
approved these changes
Jul 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Implements PIP-487 by adding OpenTelemetry event-count metrics for InflightReadsLimiter acquire/release operations and validating them with new unit tests.
Changes:
- Add two new OTel
LongCountermetrics to count successful acquire and release events. - Increment the counters in
internalAcquire,handleQueuedHandle, andinternalRelease. - Add tests that assert counter behavior for normal operation and the “permits > max” path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiter.java | Adds OTel counters for acquire/release counts and increments them at the relevant state transitions. |
| managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiterTest.java | Adds new tests and helper assertions to validate the new counter metrics. |
Comment on lines
+131
to
+142
| inflightReadsAcquireCountCounter = meter | ||
| .counterBuilder(INFLIGHT_READS_LIMITER_ACQUIRE_COUNT_METRIC_NAME) | ||
| .setDescription("The number of times inflight read permits were acquired, " | ||
| + "decreasing the remaining bytes.") | ||
| .setUnit("{event}") | ||
| .build(); | ||
| inflightReadsReleaseCountCounter = meter | ||
| .counterBuilder(INFLIGHT_READS_LIMITER_RELEASE_COUNT_METRIC_NAME) | ||
| .setDescription("The number of times inflight read permits were released, " | ||
| + "increasing the remaining bytes.") | ||
| .setUnit("{event}") | ||
| .build(); |
Comment on lines
+654
to
+665
| private static void assertMetricCount(Collection<MetricData> metrics, String metricName, long expectedValue) { | ||
| var matches = metrics.stream() | ||
| .filter(m -> m.getName().equals(metricName)) | ||
| .collect(Collectors.toList()); | ||
| if (expectedValue == 0 && matches.isEmpty()) { | ||
| return; | ||
| } | ||
| assertThat(matches).hasSize(1); | ||
| assertThat(matches.get(0)) | ||
| .hasLongSumSatisfying(longSum -> longSum.hasPointsSatisfying( | ||
| point -> point.hasValue(expectedValue))); | ||
| } |
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.
Motivation & Modifications
See #26092
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes