Skip to content
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

[Question] Does MeterBinder needs to be thread safe? #5461

Open
kkocel opened this issue Sep 2, 2024 · 2 comments
Open

[Question] Does MeterBinder needs to be thread safe? #5461

kkocel opened this issue Sep 2, 2024 · 2 comments
Labels
doc-update A documentation update
Milestone

Comments

@kkocel
Copy link

kkocel commented Sep 2, 2024

Should I make my MeterBinder implementations thread-safe? Docs do not specify that...

@shakuzen shakuzen added the doc-update A documentation update label Sep 12, 2024
@shakuzen shakuzen added this to the 1.9.x milestone Sep 12, 2024
@shakuzen
Copy link
Member

Thank you for the question. It has sparked some discussion among the team. We will update documentation on this.

MeterBinder instances generally aren't expected to have bindTo called often. Typically it would be expected that it is called on MeterRegistry instances at configuration time for an application. However, I think even our own MeterBinder implementations may not be consistent on whether the implementation is done in such a way that the same MeterBinder instance can be bound to multiple registries without issue. So I think that's a question/expectation to decide on before answering about thread safety. By thread safe, do you mean when bindTo is called concurrently for the same MeterBinder instance? Do you have a use case in which you expect this to happen with some MeterBinder, or is it just a general question about implementation concerns?

@kkocel
Copy link
Author

kkocel commented Sep 12, 2024

It's more about implementation concerns - I've seen bindTo methods in some libraries that use synchronized keywords or ReentrantLock and micrometer implementations that do not use such mechanisms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-update A documentation update
Projects
None yet
Development

No branches or pull requests

2 participants