-
Notifications
You must be signed in to change notification settings - Fork 2k
enhancement(observability): Add _utilization_mean buffer metrics
#24453
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0e86c1c
chore(core): Move `AtomicF64` type into `vector-common`
bruceg d442fbd
chore(core): Move `stats` module to `vector-common`
bruceg 5f1e365
chore(core): Add new `AtomicEwma` type
bruceg e5949b8
enhancement(observability): Add `_utilization_mean` buffer metrics
bruceg 4919784
Fix buffer utilization test counts for added metric
bruceg 1a61e90
Update wording of new metric documentation
bruceg 75e8243
Tweak outputs wording
bruceg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Added moving-mean gauges for source and transform buffers (`source_buffer_utilization_mean` and `transform_buffer_utilization_mean`), so observers can track an EWMA of buffer utilization in addition to the instant level. | ||
|
|
||
| authors: bruceg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| use std::sync::atomic::{AtomicU64, Ordering}; | ||
|
|
||
| use metrics::GaugeFn; | ||
|
|
||
| /// Simple atomic wrapper for `f64` values. | ||
| #[derive(Debug)] | ||
| pub struct AtomicF64(AtomicU64); | ||
|
|
||
| impl AtomicF64 { | ||
| /// Creates a new `AtomicF64` with the given initial value. | ||
| #[must_use] | ||
| pub fn new(init: f64) -> Self { | ||
| Self(AtomicU64::new(init.to_bits())) | ||
| } | ||
|
|
||
| pub fn load(&self, order: Ordering) -> f64 { | ||
| f64::from_bits(self.0.load(order)) | ||
| } | ||
|
|
||
| #[expect(clippy::missing_panics_doc, reason = "fetch_update always succeeds")] | ||
| pub fn fetch_update( | ||
| &self, | ||
| set_order: Ordering, | ||
| fetch_order: Ordering, | ||
| mut f: impl FnMut(f64) -> f64, | ||
| ) -> f64 { | ||
| f64::from_bits( | ||
| self.0 | ||
| .fetch_update(set_order, fetch_order, |x| { | ||
| Some(f(f64::from_bits(x)).to_bits()) | ||
| }) | ||
| .expect("fetch_update always succeeds"), | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| impl GaugeFn for AtomicF64 { | ||
| fn increment(&self, amount: f64) { | ||
| self.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |value| value + amount); | ||
| } | ||
|
|
||
| fn decrement(&self, amount: f64) { | ||
| self.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |value| value - amount); | ||
| } | ||
|
|
||
| fn set(&self, value: f64) { | ||
| self.0.store(f64::to_bits(value), Ordering::Relaxed); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this would work the same as fetch_update returns an f64
Uh oh!
There was an error while loading. Please reload this page.
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.
The issue is that
fetch_updatereturns the old value (hence the mnemonics of fetch-then-update), but we want to return the updated average which is only accessible in the closure or by adding another fetch which adds to the expense.