You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when there are multiple AsyncInstrument, each metric has its own independent with_callback to set an update callback. I would like to be able to update multiple related metrics in a single callback. For example, when retrieving Linux memory information, we typically only need to read from /proc once to get both total memory and free memory. However, currently, I have to register separate callbacks for total memory and free memory, which leads to multiple reads from /proc.
OpenTelemetry Java provides a batchCallback function to achieve this functionality, and I hope a similar interface can be available in Rust as well.
// call an expensive API to get some values.
// let value = expensive_api_call();
// observer.observer(value);
// call an expensive API to get some values and cache it
// if cache is old, call expensive API again.
// {
// let cache = expensive_api_call();
// }
// observer.observer(cache);
One suggested alternate. Not as elegant.
Consider reprioritizing this for 1.0 itself given there are many asks.
Related Problems?
No response
Describe the solution you'd like:
Currently, when there are multiple
AsyncInstrument
, each metric has its own independentwith_callback
to set an update callback. I would like to be able to update multiple related metrics in a single callback. For example, when retrieving Linux memory information, we typically only need to read from/proc
once to get bothtotal memory
andfree memory
. However, currently, I have to register separate callbacks fortotal memory
andfree memory
, which leads to multiple reads from/proc
.See:
batchCallback
See: multiple-instrument-callbacks
Considered Alternatives
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: