-
Notifications
You must be signed in to change notification settings - Fork 848
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
Log warning when duplicate async instruments are registered #4020
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4020 +/- ##
============================================
+ Coverage 89.90% 89.93% +0.03%
- Complexity 4310 4316 +6
============================================
Files 513 513
Lines 13079 13091 +12
Branches 1266 1268 +2
============================================
+ Hits 11759 11774 +15
+ Misses 915 914 -1
+ Partials 405 403 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, although codecov complains about new cov < 80% ;)
There's one valid use case of multiple registrations that I would like an answer to (via batch API) before we lock this down. Specifically, registering callbacks that report different attributes.
Nominally, users could just put each observation in a single callback and maybe that's ok. Just want to make sure we document HOW we want users to do that, especially if we lock down use cases. |
Small clarification - this PR doesn't change the behavior. If you register multiple callbacks today the first will be called and subsequent ones are silently ignored. This just tries to help users debug why their callback isn't being called. I think we have to recommend that for now. An option for users is to use a helper function to transform several callbacks into a composite callback:
|
There's an outstanding issue related to registering multiple async callbacks here. I believe its possible to support this type of use case by. We'd simply have to make However, the issue references that the spec is the limiting factor right now, which is likely due to the following section:
Thinking about it more and my other comment, a user could implement their own mutable callback to solve that problem. For example:
|
Just for the record, I've encountered exactly this case in my Micrometer instrumentation -- ended up implementing a mutable composite callback, works fine; especially when you have to stop/remove certain measurements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this logging in, and if we do in the future allow multiple callbacks even with the same API, it would be accepting more input than before by removing the log message and a semver-comaptible change
Resolves #4005.
The example in the issue now yields the following results: