Open jonatan-ivanov opened 3 years ago
/cc: @reyang @jmacd @jkwatson
Discussed during 10/14/2021 #210 Metrics SIG Meeting, we haven't seen many demands and this is one possible way among many other ways to provide simpler API for specific scenarios. Move this out of the initial stable release scope.
If anyone interested in this addition, please reply here and describe your usage scenario.
Right now, the Metrics API Docs says:
Measurements
encapsulate two things:Attributes
(dimensions)This means that if the users have a function that provides a value (provided by a library/language sdk/etc.), they can't just simply use it but they have to wrap it in another function that enhances the original one and adds the attributes. This can result in sub-optimal user experience and API usability by forcing the users to write a bunch of boilerplate.
Can we come up with a solution (additional functionality) to improve this so that the users can register a simple function that only provides the value and if they want define the attributes separately?
For example:
With "static" attributes:
You can call it like this (the
sensor
instance has agetTemperature
method that returns aDouble
and it is registered as the callback):With "dynamic" attributes:
You can call it like this (the
sensor
instance has agetTemperature
method that returns aTemperatureResult
instance that will be passed to theattributesProvider
which will provide the Attributes based on the result):