Skip to content
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

[Feature]: Multiple instrument callbacks #2151

Open
lh123 opened this issue Sep 27, 2024 · 3 comments
Open

[Feature]: Multiple instrument callbacks #2151

lh123 opened this issue Sep 27, 2024 · 3 comments
Labels
A-metrics Area: issues related to metrics enhancement New feature or request

Comments

@lh123
Copy link

lh123 commented Sep 27, 2024

Related Problems?

No response

Describe the solution you'd like:

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.

See: batchCallback

See: multiple-instrument-callbacks

Considered Alternatives

No response

Additional Context

No response

@lh123 lh123 added enhancement New feature or request triage:todo Needs to be traiged. labels Sep 27, 2024
@lh123 lh123 changed the title [Feature]: Batch Callback Update AsyncInstrument [Feature]: Batch Callback to Update Multiple AsyncInstruments Sep 27, 2024
@lh123 lh123 changed the title [Feature]: Batch Callback to Update Multiple AsyncInstruments [Feature]: Multiple instrument callbacks Sep 27, 2024
@cijothomas cijothomas added A-metrics Area: issues related to metrics and removed triage:todo Needs to be traiged. labels Sep 27, 2024
@cijothomas
Copy link
Member

This capability was intentionally removed here to keep 1.0 scope minimal. We can consider adding this post 1.0, as this would be a additive change.

@cijothomas
Copy link
Member

@stormshield-fabs Also raised interest in making this happen.

@cijothomas
Copy link
Member

// 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metrics Area: issues related to metrics enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants