@@ -6,6 +6,8 @@ use crate::runtime::TaskMeta;
6
6
use crate :: runtime:: { blocking, driver, Callback , HistogramBuilder , Runtime , TaskCallback } ;
7
7
use crate :: util:: rand:: { RngSeed , RngSeedGenerator } ;
8
8
9
+ #[ cfg( tokio_unstable) ]
10
+ use crate :: runtime:: metrics:: HistogramConfiguration ;
9
11
use std:: fmt;
10
12
use std:: io;
11
13
use std:: time:: Duration ;
@@ -1114,8 +1116,29 @@ impl Builder {
1114
1116
/// .build()
1115
1117
/// .unwrap();
1116
1118
/// ```
1119
+ #[ deprecated( note = "use metrics_poll_count_histogram_configuration" ) ]
1117
1120
pub fn metrics_poll_count_histogram_scale( & mut self , histogram_scale: crate :: runtime:: HistogramScale ) -> & mut Self {
1118
- self . metrics_poll_count_histogram. scale = histogram_scale;
1121
+ self . metrics_poll_count_histogram. legacy_mut( |b|b. scale = histogram_scale) ;
1122
+ self
1123
+ }
1124
+
1125
+ /// Configure the poll_count histogram
1126
+ ///
1127
+ /// # Examples
1128
+ /// Configure the default `LogHistogram`:
1129
+ /// ```
1130
+ /// use tokio::runtime;
1131
+ /// use std::time::Duration;
1132
+ /// use tokio::runtime::{HistogramConfiguration, LogHistogram};
1133
+ ///
1134
+ /// let rt = runtime::Builder::new_multi_thread()
1135
+ /// .enable_metrics_poll_count_histogram()
1136
+ /// .metrics_poll_count_histogram_configuration(HistogramConfiguration::log(LogHistogram::default()))
1137
+ /// .build()
1138
+ /// .unwrap();
1139
+ /// ```
1140
+ pub fn metrics_poll_count_histogram_configuration( & mut self , configuration: HistogramConfiguration ) -> & mut Self {
1141
+ self . metrics_poll_count_histogram. histogram_type = configuration. inner;
1119
1142
self
1120
1143
}
1121
1144
@@ -1145,13 +1168,15 @@ impl Builder {
1145
1168
/// .build()
1146
1169
/// .unwrap();
1147
1170
/// ```
1171
+ #[ deprecated( note = "use metrics_poll_count_histogram_configuration" ) ]
1148
1172
pub fn metrics_poll_count_histogram_resolution( & mut self , resolution: Duration ) -> & mut Self {
1149
1173
assert!( resolution > Duration :: from_secs( 0 ) ) ;
1150
1174
// Sanity check the argument and also make the cast below safe.
1151
1175
assert!( resolution <= Duration :: from_secs( 1 ) ) ;
1152
1176
1153
1177
let resolution = resolution. as_nanos( ) as u64 ;
1154
- self . metrics_poll_count_histogram. resolution = resolution;
1178
+
1179
+ self . metrics_poll_count_histogram. legacy_mut( |b|b. resolution = resolution) ;
1155
1180
self
1156
1181
}
1157
1182
@@ -1176,8 +1201,9 @@ impl Builder {
1176
1201
/// .build()
1177
1202
/// .unwrap();
1178
1203
/// ```
1204
+ #[ deprecated( note = "use `metrics_poll_count_histogram_configuration" ) ]
1179
1205
pub fn metrics_poll_count_histogram_buckets( & mut self , buckets: usize ) -> & mut Self {
1180
- self . metrics_poll_count_histogram. num_buckets = buckets;
1206
+ self . metrics_poll_count_histogram. legacy_mut ( |b|b . num_buckets = buckets) ;
1181
1207
self
1182
1208
}
1183
1209
}
0 commit comments