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

tracing: mpsc channel size metrics #6314

Closed
barafael opened this issue Jan 30, 2024 · 5 comments · Fixed by #6348
Closed

tracing: mpsc channel size metrics #6314

barafael opened this issue Jan 30, 2024 · 5 comments · Fixed by #6348
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-sync Module: tokio/sync M-tracing Tracing support in Tokio

Comments

@barafael
Copy link
Contributor

barafael commented Jan 30, 2024

I'm usually choosing channel sizes intuitively. I frequently miss having empirical data on how full the channels in my system are during normal operation or more exotic load situations.

I'd like to either have public functions on the mpsc::Sender that allow me to see how many elements are in there, like crossbeam::channel::Sender::len.

It would also be fine to emit the channel length as a metric of sorts, like attempted in this PR.

@barafael barafael added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Jan 30, 2024
@Darksonn Darksonn added M-sync Module: tokio/sync M-tracing Tracing support in Tokio labels Jan 31, 2024
@Darksonn
Copy link
Contributor

Adding a Sender::len method seems reasonable enough. More complex solutions with tracing would need more details on exactly what is being proposed.

@barafael
Copy link
Contributor Author

barafael commented Feb 12, 2024

The Sender::len would be completely sufficient for me, it seems like a worthwhile API addition. Should also be available on WeakSender probably. I'll take a shot at it, would you mind pointing me in a direction?

@Darksonn
Copy link
Contributor

You should probably add a method here, and use it to provide a len method on the Rx/Tx types in chan.rs. Then you can add methods on the user-facing channel types that call these methods.

@barafael
Copy link
Contributor Author

Actually, I think simply tx.max_capacity() - tx.capacity() does exactly what I need. I'm not sure this warrants an extra method?

@Darksonn
Copy link
Contributor

Hmm, there's no equivalent to that for the unbounded channel, so I am still okay with adding a len method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-sync Module: tokio/sync M-tracing Tracing support in Tokio
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants