Skip to content

[improve][broker] Implemets PIP-487: add event count metrics for InflightReadsLimiter acquire and release operations - #26093

Merged
poorbarcode merged 2 commits into
apache:masterfrom
poorbarcode:improve/inflight_reading_release_counter
Jul 15, 2026
Merged

poorbarcode merged 2 commits into
apache:masterfrom
poorbarcode:improve/inflight_reading_release_counter

Conversation

@poorbarcode

Copy link
Copy Markdown
Contributor

Motivation & Modifications

See #26092

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

@poorbarcode
poorbarcode merged commit 1b32aa8 into apache:master Jul 15, 2026
44 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 LongCounter metrics to count successful acquire and release events.
  • Increment the counters in internalAcquire, handleQueuedHandle, and internalRelease.
  • 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)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants