tokio-rs/tokio-metrics

Is it worth tracking/exposing `num_scheduled`?

jswrenn opened this issue · 1 comments

I think num_scheduled is going to equal num_polls - num_tasks? Need to double-check this, but if so, it doesn't need to be a field in the Metrics struct; it could be computed in a method, instead.

Should it even be exposed? @carllerche points out that this metric matters much more at the runtime level, since there are multiple ways tasks may be scheduled. For task metrics, what matters more is time spent scheduled. At least internally, we need to account for num_scheduled so we can compute mean_time_scheduled, but maybe num_scheduled doesn't actually need to be exposed.

Decided to keep this exposed, and as a field in the TaskMetrics struct. The metric pulls its weight in the Why are my tasks slow? documentation. I kept it as a field in TaskMetrics (rather than a method), to stick with the pattern where the base metrics are fields, and derived metrics (e.g., averages) are methods.