Remove ExemplarReservoir generic type #7742
Closed
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.
Related to #7636, #7503.
ExemplarReservoir currently has the signature:
ExemplarReservoir<T extends ExemplarData>
, whereT
is eitherLongExemplarData
orDoubleExemplarData
.This parameter is used in the collect method, which has signature:
List<T> collectAndReset(Attributes pointAttributes)
This is problematic because according to the spec, ExemplarReservoir needs to be configurable via views. Views do not have a generic type indicating applicability to longs or doubles. A single view can apply to many instruments, and both double and long instruments simultaneously.
We need to resolve this mismatch before stabilizing the ExemplarReservoir interface. This PR suggests doing that by removing the generic type from ExemplarReservoir and instead giving ExemplarReservoir collection methods for both longs and doubles:
List<DoubleExemplarData> collectAndResetDoubles(Attributes pointAttributes)
List<LongExemplarData> collectAndResetLongs(Attributes pointAttributes)
This brings symmetry to recording, since ExemplarReservoir currently has both double and long methods for recording values.
Alternatively, we could have separate
DoubleExemplarReservoir
andLongExemplarReservoir
types, and a newExemplarReservoirFactory
with methodscreateDoubleExemplarReservoir(..)
,createLongExemplarReservoir(..)
. Then it would be theExemplarReservoirFactory
which users would configure on views. I think this will end up being more cumbersome and awkward for users to implement.