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

move metered-channel to mysten-metrics #12156

Merged
merged 1 commit into from
May 23, 2023

Conversation

longbowlu
Copy link
Collaborator

@longbowlu longbowlu commented May 23, 2023

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)

  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • breaking change for validators or node operators (must upgrade binaries)
  • breaking change for on-chain data layout
  • necessitate either a data wipe or data migration

Release notes

Moves metered-channel from narwhal to mysten-metrics and uses it on streamer to monitor the channel size.

@vercel
Copy link

vercel bot commented May 23, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
offline-signer-helper ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2023 3:46am
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) May 23, 2023 3:46am
explorer-storybook ⬜️ Ignored (Inspect) May 23, 2023 3:46am
sui-wallet-kit ⬜️ Ignored (Inspect) May 23, 2023 3:46am
wallet-adapter ⬜️ Ignored (Inspect) May 23, 2023 3:46am

@longbowlu longbowlu requested review from mwtian and arun-koshy May 23, 2023 00:51
@longbowlu longbowlu marked this pull request as ready for review May 23, 2023 00:51
Comment on lines +38 to +51
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();
Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

@mwtian mwtian left a 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.

channels: register_int_gauge_vec_with_registry!(
"monitored_channels",
"Size of channels per callsite.",
&["callsite"],
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Collaborator Author

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

@longbowlu longbowlu force-pushed the move-metered-channel-to-mysten-metrics branch from a5be4b4 to c21861d Compare May 23, 2023 03:45
@longbowlu longbowlu enabled auto-merge (squash) May 23, 2023 03:51
@longbowlu longbowlu merged commit 5fd9a2e into main May 23, 2023
@longbowlu longbowlu deleted the move-metered-channel-to-mysten-metrics branch May 23, 2023 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants