Repository navigation
Conversation
Co-authored-by: Skarm <skarm@users.noreply.github.com>
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.
RecordStatsdiscards the callback registration, leaving callers without a way to stop observations or release the callback's reference to a pool before meter-provider shutdown.Add
RegisterStats(pool, options...) (func() error, error). Its cleanup function serializes concurrent calls, unregisters the callback and releases retained pool/stat references. Failed cleanup can be retried; successful cleanup is idempotent. Keep the existingRecordStatssignature and provider-lifetime behavior.Support callbacks invoked synchronously during registration. On registration failure, deactivate the callback and release pool references before attempting to unregister a partial registration. This also handles an unregister failure: the retained callback stops observing the pool, and both errors are returned.
Validation:
meter_test.gocover independent registrations, concurrent cleanup, collection in progress, provider shutdown, cleanup retry, registration errors and failures at each of the 13 instrument creation sites.main; the partial-registration test reproduces continued pool reads on the initial branch. Both pass with the final code.make test,go mod tidy -diffand golangci-lint 2.12.2 pass on Go 1.25.0/1.26.9; race tests pass on Go 1.25.0/1.27.2. Additional review diagnostics check concurrent readers and reference release while the callback or cleanup function remains live.pool.Close()does not automatically unregister statistics. The existingPoolStatsinterface is unchanged; no polling goroutine, finalizer or production dependency is added.