@@ -731,7 +731,7 @@ impl RuntimeMetrics {
731
731
///
732
732
/// Task poll times are not instrumented by default as doing so requires
733
733
/// calling [`Instant::now()`] twice per task poll. The feature is enabled
734
- /// by calling [`enable_metrics_poll_count_histogram ()`] when building the
734
+ /// by calling [`enable_metrics_poll_time_histogram ()`] when building the
735
735
/// runtime.
736
736
///
737
737
/// # Examples
@@ -741,33 +741,39 @@ impl RuntimeMetrics {
741
741
///
742
742
/// fn main() {
743
743
/// runtime::Builder::new_current_thread()
744
- /// .enable_metrics_poll_count_histogram ()
744
+ /// .enable_metrics_poll_time_histogram ()
745
745
/// .build()
746
746
/// .unwrap()
747
747
/// .block_on(async {
748
748
/// let metrics = Handle::current().metrics();
749
- /// let enabled = metrics.poll_count_histogram_enabled ();
749
+ /// let enabled = metrics.poll_time_histogram_enabled ();
750
750
///
751
751
/// println!("Tracking task poll time distribution: {:?}", enabled);
752
752
/// });
753
753
/// }
754
754
/// ```
755
755
///
756
- /// [`enable_metrics_poll_count_histogram ()`]: crate::runtime::Builder::enable_metrics_poll_count_histogram
756
+ /// [`enable_metrics_poll_time_histogram ()`]: crate::runtime::Builder::enable_metrics_poll_time_histogram
757
757
/// [`Instant::now()`]: std::time::Instant::now
758
- pub fn poll_count_histogram_enabled ( & self ) -> bool {
758
+ pub fn poll_time_histogram_enabled ( & self ) -> bool {
759
759
self . handle
760
760
. inner
761
761
. worker_metrics( 0 )
762
762
. poll_count_histogram
763
763
. is_some( )
764
764
}
765
765
766
+ #[ deprecated( note = "Renamed to `poll_time_histogram_enabled`" ) ]
767
+ #[ doc( hidden) ]
768
+ pub fn poll_count_histogram_enabled( & self ) -> bool {
769
+ self . poll_time_histogram_enabled( )
770
+ }
771
+
766
772
/// Returns the number of histogram buckets tracking the distribution of
767
773
/// task poll times.
768
774
///
769
775
/// This value is configured by calling
770
- /// [`metrics_poll_count_histogram_configuration ()`] when building the runtime.
776
+ /// [`metrics_poll_time_histogram_configuration ()`] when building the runtime.
771
777
///
772
778
/// # Examples
773
779
///
@@ -776,21 +782,21 @@ impl RuntimeMetrics {
776
782
///
777
783
/// fn main() {
778
784
/// runtime::Builder::new_current_thread()
779
- /// .enable_metrics_poll_count_histogram ()
785
+ /// .enable_metrics_poll_time_histogram ()
780
786
/// .build()
781
787
/// .unwrap()
782
788
/// .block_on(async {
783
789
/// let metrics = Handle::current().metrics();
784
- /// let buckets = metrics.poll_count_histogram_num_buckets ();
790
+ /// let buckets = metrics.poll_time_histogram_num_buckets ();
785
791
///
786
792
/// println!("Histogram buckets: {:?}", buckets);
787
793
/// });
788
794
/// }
789
795
/// ```
790
796
///
791
- /// [`metrics_poll_count_histogram_configuration ()`]:
792
- /// crate::runtime::Builder::metrics_poll_count_histogram_configuration
793
- pub fn poll_count_histogram_num_buckets ( & self ) -> usize {
797
+ /// [`metrics_poll_time_histogram_configuration ()`]:
798
+ /// crate::runtime::Builder::metrics_poll_time_histogram_configuration
799
+ pub fn poll_time_histogram_num_buckets ( & self ) -> usize {
794
800
self . handle
795
801
. inner
796
802
. worker_metrics( 0 )
@@ -800,15 +806,24 @@ impl RuntimeMetrics {
800
806
. unwrap_or_default( )
801
807
}
802
808
809
+ /// Deprecated. Use [`poll_time_histogram_num_buckets()`] instead.
810
+ ///
811
+ /// [`poll_time_histogram_num_buckets()`]: Self::poll_time_histogram_num_buckets
812
+ #[ doc( hidden) ]
813
+ #[ deprecated( note = "renamed to `poll_time_histogram_num_buckets`." ) ]
814
+ pub fn poll_count_histogram_num_buckets( & self ) -> usize {
815
+ self . poll_time_histogram_num_buckets( )
816
+ }
817
+
803
818
/// Returns the range of task poll times tracked by the given bucket.
804
819
///
805
820
/// This value is configured by calling
806
- /// [`metrics_poll_count_histogram_configuration ()`] when building the runtime.
821
+ /// [`metrics_poll_time_histogram_configuration ()`] when building the runtime.
807
822
///
808
823
/// # Panics
809
824
///
810
825
/// The method panics if `bucket` represents an invalid bucket index, i.e.
811
- /// is greater than or equal to `poll_count_histogram_num_buckets ()`.
826
+ /// is greater than or equal to `poll_time_histogram_num_buckets ()`.
812
827
///
813
828
/// # Examples
814
829
///
@@ -817,25 +832,25 @@ impl RuntimeMetrics {
817
832
///
818
833
/// fn main() {
819
834
/// runtime::Builder::new_current_thread()
820
- /// .enable_metrics_poll_count_histogram ()
835
+ /// .enable_metrics_poll_time_histogram ()
821
836
/// .build()
822
837
/// .unwrap()
823
838
/// .block_on(async {
824
839
/// let metrics = Handle::current().metrics();
825
- /// let buckets = metrics.poll_count_histogram_num_buckets ();
840
+ /// let buckets = metrics.poll_time_histogram_num_buckets ();
826
841
///
827
842
/// for i in 0..buckets {
828
- /// let range = metrics.poll_count_histogram_bucket_range (i);
843
+ /// let range = metrics.poll_time_histogram_bucket_range (i);
829
844
/// println!("Histogram bucket {} range: {:?}", i, range);
830
845
/// }
831
846
/// });
832
847
/// }
833
848
/// ```
834
849
///
835
- /// [`metrics_poll_count_histogram_configuration ()`]:
836
- /// crate::runtime::Builder::metrics_poll_count_histogram_configuration
850
+ /// [`metrics_poll_time_histogram_configuration ()`]:
851
+ /// crate::runtime::Builder::metrics_poll_time_histogram_configuration
837
852
#[ track_caller]
838
- pub fn poll_count_histogram_bucket_range ( & self , bucket: usize ) -> Range <Duration > {
853
+ pub fn poll_time_histogram_bucket_range ( & self , bucket: usize ) -> Range <Duration > {
839
854
self . handle
840
855
. inner
841
856
. worker_metrics( 0 )
@@ -851,6 +866,16 @@ impl RuntimeMetrics {
851
866
. unwrap_or_default( )
852
867
}
853
868
869
+ /// Deprecated. Use [`poll_time_histogram_bucket_range()`] instead.
870
+ ///
871
+ /// [`poll_time_histogram_bucket_range()`]: Self::poll_time_histogram_bucket_range
872
+ #[ track_caller]
873
+ #[ doc( hidden) ]
874
+ #[ deprecated( note = "renamed to `poll_time_histogram_bucket_range`" ) ]
875
+ pub fn poll_count_histogram_bucket_range( & self , bucket: usize ) -> Range <Duration > {
876
+ self . poll_time_histogram_bucket_range( bucket)
877
+ }
878
+
854
879
cfg_64bit_metrics! {
855
880
/// Returns the number of times the given worker polled tasks with a poll
856
881
/// duration within the given bucket's range.
@@ -872,7 +897,7 @@ impl RuntimeMetrics {
872
897
///
873
898
/// `bucket` is the index of the bucket being queried. The bucket is scoped
874
899
/// to the worker. The range represented by the bucket can be queried by
875
- /// calling [`poll_count_histogram_bucket_range ()`]. Each worker maintains
900
+ /// calling [`poll_time_histogram_bucket_range ()`]. Each worker maintains
876
901
/// identical bucket ranges.
877
902
///
878
903
/// # Panics
@@ -888,26 +913,26 @@ impl RuntimeMetrics {
888
913
///
889
914
/// fn main() {
890
915
/// runtime::Builder::new_current_thread()
891
- /// .enable_metrics_poll_count_histogram ()
916
+ /// .enable_metrics_poll_time_histogram ()
892
917
/// .build()
893
918
/// .unwrap()
894
919
/// .block_on(async {
895
920
/// let metrics = Handle::current().metrics();
896
- /// let buckets = metrics.poll_count_histogram_num_buckets ();
921
+ /// let buckets = metrics.poll_time_histogram_num_buckets ();
897
922
///
898
923
/// for worker in 0..metrics.num_workers() {
899
924
/// for i in 0..buckets {
900
- /// let count = metrics.poll_count_histogram_bucket_count (worker, i);
925
+ /// let count = metrics.poll_time_histogram_bucket_count (worker, i);
901
926
/// println!("Poll count {}", count);
902
927
/// }
903
928
/// }
904
929
/// });
905
930
/// }
906
931
/// ```
907
932
///
908
- /// [`poll_count_histogram_bucket_range ()`]: crate::runtime::RuntimeMetrics::poll_count_histogram_bucket_range
933
+ /// [`poll_time_histogram_bucket_range ()`]: crate::runtime::RuntimeMetrics::poll_time_histogram_bucket_range
909
934
#[ track_caller]
910
- pub fn poll_count_histogram_bucket_count ( & self , worker: usize , bucket: usize ) -> u64 {
935
+ pub fn poll_time_histogram_bucket_count ( & self , worker: usize , bucket: usize ) -> u64 {
911
936
self . handle
912
937
. inner
913
938
. worker_metrics( worker)
@@ -917,6 +942,12 @@ impl RuntimeMetrics {
917
942
. unwrap_or_default( )
918
943
}
919
944
945
+ #[ doc( hidden) ]
946
+ #[ deprecated( note = "use `poll_time_histogram_bucket_count` instead" ) ]
947
+ pub fn poll_count_histogram_bucket_count( & self , worker: usize , bucket: usize ) -> u64 {
948
+ self . poll_time_histogram_bucket_count( worker, bucket)
949
+ }
950
+
920
951
/// Returns the mean duration of task polls, in nanoseconds.
921
952
///
922
953
/// This is an exponentially weighted moving average. Currently, this metric
0 commit comments