Add SumObserver and UpDownSumObserver instruments#789
Add SumObserver and UpDownSumObserver instruments#789lzchen merged 38 commits intoopen-telemetry:masterfrom
Conversation
opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/batcher.py
Outdated
Show resolved
Hide resolved
| """ | ||
|
|
||
|
|
||
| class SumObserver(Observer): |
There was a problem hiding this comment.
I think you need to update the ObserverT TypeVar in this file
There was a problem hiding this comment.
Currently we have ObserverT = TypeVar("ObserverT", bound=Observer). I believe as long as the class used is a subclass of "Observer" this definition should be accurate?
toumorokoshi
left a comment
There was a problem hiding this comment.
Overall a couple minor changes, but I think the code does as expected.
Unrelated to this PR per se, but: I feel like both of these observers Sum and UpDownSum, aren't super valuable.
At the end of the day, all these things do is provide a sanity check for a developer who uses them, by providing guarantees around the value itself.
Theres edge cases here especially with things like monotonic counters that will be nasty, including:
- random resets back to 0 that occur due to some internal counter in the kernel resetting, or some value outside of this. SumObserver is still the right category of observer here, but you'll be violating it's constraint through no fall of your own.
In my experience these type of constraints can be handled on the consumer side, with functions or operations like nonNegativeDerivative which will show you the rate by which something is increasing.
|
@toumorokoshi |
Co-authored-by: alrex <alrex.boten@gmail.com>
Co-authored-by: alrex <alrex.boten@gmail.com>
Resolves [#755] and [#756]
Abstracts
Observerinstrument as a base class for all asynchronous instruments.SumObserver and UpDownSumObserver are also cumulative, so they use the LastValueAggregator to record.
Observed values must also be non-decreasing, compared to the previous observed value for SumObserver. Observed values can be any value for UpDownSumObserver .