Skip to content

Close pool gauge registrations on shutdown - #735

Merged
alex268 merged 4 commits into
masterfrom
codex/pool-gauge-registration-lifecycle
Oct 1, 2026
Merged

alex268 merged 4 commits into
masterfrom
codex/pool-gauge-registration-lifecycle

Conversation

@KirillKurdyukov

@KirillKurdyukov KirillKurdyukov commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Release observable gauge callbacks when table/query session pools close, following the C# reporter registration/disposal lifecycle.

  • New Meter.registerLongGauge returns a closeable MetricRegistration.
  • OpenTelemetryMeter wraps the native gauge in a private GaugeRegistration with a final field and delegates close() directly.
  • Shared PoolMetrics owns its four gauge registrations; both table and query pool owners close them.

Gauge names, units, values, counter paths and session/queue behavior remain unchanged. No Topic changes are included. This is the prerequisite for rebasing and correcting Topic gauges in #734 after this PR is merged.

Existing void Meter.createLongGauge remains source/binary compatible and is marked @Deprecated. The new method has a default implementation that calls the legacy override and returns MetricRegistration.NOOP. Backends override registerLongGauge to support callback removal; existing custom backends keep their previous lifecycle.

Validation

Java21 SDK clean install passed 69 tests: core6, table42, query21; no failures, errors or skips. This includes legacy API compatibility and callback removal.

Current JDBC source compiled all 89 production and 55 test files against the local SDK2.4.12-SNAPSHOT. Its 89 settings tests passed without failures/errors/skips, including the unchanged legacy BadCustomMeter implementation.

JAVA_HOME=$(/usr/libexec/java_home -v 21) mvn -B -pl query -am \
  '-Dtest=OpenTelemetryMeterTest,PoolMetricsTest,SessionPoolTest,WaitingQueueTest' \
  -Dsurefire.failIfNoSpecifiedTests=false clean install

Public SDK smoke with two TableClient instances and a real OpenTelemetry collector:

Action Exported gauge points
Create two pools with distinct pool names 10 points across four instruments
Close the first pool Five points belonging only to the second
Close the first pool again Gauge values remain unchanged; repeated close is delegated to the backend
Close both pools None

NOOP registrations can be closed repeatedly. The same scenario fails when callback handles are discarded, reproducing the original leak.

The native OpenTelemetry backend logs a warning for repeated close; the wrapper adds no atomics, mutable state or duplicate-close guard.

CI compatibility

The previous JDBC BadCustomMeter compilation failure is fixed by retaining the old void signature. JDBC sources are unchanged. Local database integration tests were not run because Docker is not running; the CI matrix will exercise the complete downstream suites.

Deprecation warnings from compatibility tests and native OpenTelemetry warnings on repeated close are expected and not suppressed.

@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.69%. Comparing base (79ef25c) to head (bc34550).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #735      +/-   ##
============================================
+ Coverage     74.54%   74.69%   +0.14%     
- Complexity     3654     3667      +13     
============================================
  Files           393      394       +1     
  Lines         16606    16623      +17     
  Branches       1756     1756              
============================================
+ Hits          12379    12416      +37     
+ Misses         3603     3593      -10     
+ Partials        624      614      -10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alex268
alex268 merged commit 01a0b6b into master Oct 1, 2026
13 checks passed
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.

2 participants