-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
move metered-channel to mysten-metrics #12156
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
let gauge = if let Some(metrics) = mysten_metrics::get_metrics() { | ||
metrics.channels.with_label_values(&["streamer"]) | ||
} else { | ||
// We call init_metrics very early when starting a node. Therefore when this happens, | ||
// it's probably in a test. | ||
mysten_metrics::init_metrics(&Registry::default()); | ||
mysten_metrics::get_metrics() | ||
.unwrap() | ||
.channels | ||
.with_label_values(&["streamer"]) | ||
}; | ||
|
||
let (tx, rx) = mysten_metrics::metered_channel::channel(buffer, &gauge); | ||
let gague_clone = gauge.clone(); |
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 is the meat of this PR
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.
Is it possible to extract the logic to a fn monitored_channel(buffer_size: usize, name: &'static str)
in mysten-metrics
? It would be useful elsewhere too.
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.
yeah I want to clean this up eventually, adding a TODO
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.
Looks good and I think adding two metrics for each channel in other callsites are a bit of a pain and in future, we should use labels per channel everywhere instead.
crates/mysten-metrics/src/lib.rs
Outdated
channels: register_int_gauge_vec_with_registry!( | ||
"monitored_channels", | ||
"Size of channels per callsite.", | ||
&["callsite"], |
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.
Maybe call the label name
? Other callsite
labels have actual file:line
as values.
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 thought about it and thought it would be more consistent if we stick with one label for these monitored
metrics
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.
monitored_scope is using 'name' as label name. We may migrate monitored tasks and futures too.
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.
you are right, I will use name
for this
a5be4b4
to
c21861d
Compare
Description
This PR moves metered-channel from narwhal to mysten-metrics and uses it on
streamer
to monitor the channel size.Test Plan
Tested it locally and see the metrics appeared.
If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.
Type of Change (Check all that apply)
Release notes
Moves metered-channel from narwhal to mysten-metrics and uses it on
streamer
to monitor the channel size.