-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix observable attributes drop #2557
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the fix
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.md
updated for non-trivial changes