Clarify whether multiple callbacks are allowed for async instruments #2249
Labels
area:api
Cross language API specification issue
enhancement
New feature or request
needs discussion
Need more information before all suitable labels can be applied
spec:metrics
Related to the specification/metrics directory
Milestone
What are you trying to achieve?
Clarify behavior of metrics API / SDK when multiple callbacks are registered to the same instrument. The api spec says:
In java, we interpret that as meaning that you can't register conflicting instruments under the same name. However, if the instrument type, name, unit, and description match, we'll return the previously registered instrument.
For example, in the following snippet, no error is generated and
counter1
andcounter2
are the instrument.This makes sense for synchronous instruments, but its not clear what to do in the async case. Currently, if multiple callbacks are registered for the same instrument, we silently ignore registrations after the first. This isn't great, and minimally we should log an error when subsequent callbacks are registered. However, there's also an argument to made that registering multiple callbacks should be allowed and should result in each being invoked.
This has been raised in Issue #4051 and we believe it needs raising in the spec for resolution.
In particular, we want to make sure that our plans to publish a stable version of the metrics API would not be impacted by the spec resolution of this issue.
Additional context.
Issue #4005 aims to log a warning when multiple callbacks are registered, and is implemented in Issue #4020.
The text was updated successfully, but these errors were encountered: