Skip to content

Commit

Permalink
Fix missed methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh committed Oct 21, 2024
1 parent 9b25f46 commit 07ae5b1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions tokio/src/runtime/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ impl Builder {
///
/// [`enable_metrics_poll_time_histogram()`]: Builder::enable_metrics_poll_time_histogram
#[deprecated(note = "`poll_count_histogram` related methods have been renamed `poll_time_histogram` to better reflect their functionality.")]
#[doc(hidden)]
pub fn enable_metrics_poll_count_histogram(&mut self) -> &mut Self {
self.enable_metrics_poll_time_histogram()
}
Expand Down
12 changes: 8 additions & 4 deletions tokio/src/runtime/metrics/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,6 @@ impl RuntimeMetrics {
#[deprecated(note = "renamed to `poll_time_histogram_num_buckets`.")]
pub fn poll_count_histogram_num_buckets(&self) -> usize {
self.poll_time_histogram_num_buckets()

}

/// Returns the range of task poll times tracked by the given bucket.
Expand Down Expand Up @@ -923,7 +922,7 @@ impl RuntimeMetrics {
///
/// for worker in 0..metrics.num_workers() {
/// for i in 0..buckets {
/// let count = metrics.poll_count_histogram_bucket_count(worker, i);
/// let count = metrics.poll_time_histogram_bucket_count(worker, i);
/// println!("Poll count {}", count);
/// }
/// }
Expand All @@ -933,8 +932,7 @@ impl RuntimeMetrics {
///
/// [`poll_time_histogram_bucket_range()`]: crate::runtime::RuntimeMetrics::poll_time_histogram_bucket_range
#[track_caller]
#[doc(hidden)]
pub fn poll_count_histogram_bucket_count(&self, worker: usize, bucket: usize) -> u64 {
pub fn poll_time_histogram_bucket_count(&self, worker: usize, bucket: usize) -> u64 {
self.handle
.inner
.worker_metrics(worker)
Expand All @@ -944,6 +942,12 @@ impl RuntimeMetrics {
.unwrap_or_default()
}

#[doc(hidden)]
#[deprecated(note = "use `poll_time_histogram_bucket_count` instead")]
pub fn poll_count_histogram_bucket_count(&self, worker: usize, bucket: usize) -> u64 {
self.poll_time_histogram_bucket_count(worker, bucket)
}

/// Returns the mean duration of task polls, in nanoseconds.
///
/// This is an exponentially weighted moving average. Currently, this metric
Expand Down
8 changes: 4 additions & 4 deletions tokio/tests/rt_unstable_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ fn worker_poll_count_and_time() {
// Does not populate the histogram
assert!(!metrics.poll_time_histogram_enabled());
for i in 0..10 {
assert_eq!(0, metrics.poll_count_histogram_bucket_count(0, i));
assert_eq!(0, metrics.poll_time_histogram_bucket_count(0, i));
}

let rt = threaded();
Expand Down Expand Up @@ -385,7 +385,7 @@ fn worker_poll_count_and_time() {
assert!(!metrics.poll_time_histogram_enabled());
for n in 0..metrics.num_workers() {
for i in 0..10 {
assert_eq!(0, metrics.poll_count_histogram_bucket_count(n, i));
assert_eq!(0, metrics.poll_time_histogram_bucket_count(n, i));
}
}
}
Expand Down Expand Up @@ -427,7 +427,7 @@ fn log_histogram() {
);
let n = (0..metrics.num_workers())
.flat_map(|i| (0..num_buckets).map(move |j| (i, j)))
.map(|(worker, bucket)| metrics.poll_count_histogram_bucket_count(worker, bucket))
.map(|(worker, bucket)| metrics.poll_time_histogram_bucket_count(worker, bucket))
.sum();
assert_eq!(N, n);
}
Expand Down Expand Up @@ -489,7 +489,7 @@ fn worker_poll_count_histogram() {

let n = (0..num_workers)
.flat_map(|i| (0..num_buckets).map(move |j| (i, j)))
.map(|(worker, bucket)| metrics.poll_count_histogram_bucket_count(worker, bucket))
.map(|(worker, bucket)| metrics.poll_time_histogram_bucket_count(worker, bucket))
.sum();
assert_eq!(N, n);
}
Expand Down

0 comments on commit 07ae5b1

Please sign in to comment.