Fix observable attributes drop - #2557
Conversation
[pull] main from open-telemetry:main
| void Observe(T value) noexcept override { data_.insert({{}, value}); } | ||
| void Observe(T value) noexcept override | ||
| { | ||
| data_[MetricAttributes{{}, attributes_processor_}] = value; |
There was a problem hiding this comment.
This change is unrelated to the bug. Ideally, observing a value with an identical set of attributes should lead to it being overwritten. However, at present, using std::unordered_map::insert() leads to the value being disregarded rather than replaced. The observable callback shouldn't be reporting multiple values for the same attribute-set in single invoke, but fixing it just in case they do so.
| nostd::get<nostd::shared_ptr<opentelemetry::metrics::ObserverResultT<double>>>( | ||
| observer_result) | ||
| ->Observe(value_ /*, labelkv */); | ||
| ->Observe(value_, labels); |
There was a problem hiding this comment.
Tested the changes by the modified metrics example. More exhaustive tests need to be added for observable instruments, will add them along with the filtering issue fix.
|
@marcalff @ThomsonTan @esigo - I believe we need a patch release with the fix, as this is a common use-case and multiple users have reported it (few internally in my company too). I can create one (being culprit) once this is reviewed if you guys agree. |
Fix observable attributes drop (open-telemetry#2557)
Fixes #2548
Changes
PR #2472 introduced the bug to drop the attributes in Observable Instruments. This PR addresses and corrects that issue. However, there remains an unrelated, longstanding bug affecting filtering for Observable Instruments, which has never been reported. A separate bug report will be filed for that issue.
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes