Skip to content

export Close() method for subscopes #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

emmanuel-chukwu
Copy link

@emmanuel-chukwu emmanuel-chukwu commented May 21, 2025

Add ClosableScope interface to embed Scope and expose a Close() method to allow explicit cleanup of subscopes. This enables better resource management by allowing clients to:

  • Clear metrics for unused subscopes

  • Remove scopes from registry

  • Release associated resources

The method is idempotent and thread-safe, returning an error if the scope is already closed.

Add Close() method to Scope interface to allow explicit cleanup of subscopes. This enables better resource management by allowing clients to:

- Clear metrics for unused subscopes

- Remove scopes from registry

- Release associated resources

The method is idempotent and thread-safe, returning an error if the scope is already closed.
@CLAassistant
Copy link

CLAassistant commented May 21, 2025

CLA assistant check
All committers have signed the CLA.

// For root scopes, this will also close the reporter.
// For subscopes, this will clear all metrics and remove the scope from the registry.
// Returns an error if the scope is already closed.
Close() error
Copy link
Collaborator

Choose a reason for hiding this comment

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

can't do this - it's a breaking change to add a method to a go interface in semver terms

Copy link
Author

Choose a reason for hiding this comment

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

I've introduced a new ClosableScope interface to embed Scope with a Close() method

…ards-compatible way

- Introduce ClosableScope interface embedding Scope with Close() method
- Add NewClosableRootScope, TaggedClosable, and SubScopeClosable methods to obtain subscopes as ClosableScope
- Add unit tests for new ClosableScope functionality
- Preserve semver compatibility by not modifying Scope interface or method signatures
@emmanuel-chukwu emmanuel-chukwu requested a review from prateek May 26, 2025 10:32
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