Skip to content

Commit fa75e6e

Browse files
authored
chore(metrics): tune the histogram bucket for seconds/milliseconds (#17197)
* tune * cargo fmt * fix ut
1 parent d40f88c commit fa75e6e

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

โ€Žsrc/common/base/src/runtime/metrics/histogram.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ use crate::runtime::metrics::sample::MetricSample;
3030
use crate::runtime::metrics::sample::MetricValue;
3131
use crate::runtime::metrics::ScopedRegistry;
3232

33-
pub static BUCKET_SECONDS: [f64; 15] = [
34-
0.02, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0, 20.0, 30.0, 60.0, 300.0, 600.0, 1800.0,
33+
pub static BUCKET_SECONDS: [f64; 16] = [
34+
0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0, 30.0, 60.0, 300.0, 600.0, 1800.0, 3600.0, 7200.0,
35+
28800.0,
3536
];
3637

37-
pub static BUCKET_MILLISECONDS: [f64; 15] = [
38-
10.0, 50.0, 100.0, 250.0, 500.0, 1000.0, 2500.0, 5000.0, 10000.0, 20000.0, 30000.0, 60000.0,
39-
300000.0, 600000.0, 1800000.0,
38+
pub static BUCKET_MILLISECONDS: [f64; 16] = [
39+
50.0, 100.0, 250.0, 500.0, 1000.0, 2500.0, 5000.0, 10000.0, 30000.0, 60000.0, 300000.0,
40+
600000.0, 1800000.0, 3600000.0, 7200000.0, 28800000.0,
4041
];
4142

4243
pub static BUCKET_ROWS: [f64; 14] = [

โ€Žsrc/common/base/tests/it/metrics/registry.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn test_tracking_scoped_gauge_metrics() -> Result<()> {
145145
fn test_tracking_scoped_histogram_in_seconds_metrics() -> Result<()> {
146146
let uniq_metric_name = GlobalUniqName::unique();
147147
let histogram = register_histogram_in_seconds(&uniq_metric_name);
148-
histogram.observe(1801.0);
148+
histogram.observe(28801.0);
149149

150150
fn seconds_histogram_value(v: f64) -> Vec<HistogramCount> {
151151
BUCKET_SECONDS
@@ -168,7 +168,7 @@ fn test_tracking_scoped_histogram_in_seconds_metrics() -> Result<()> {
168168
new_tracking_payload.metrics = Some(scoped_registry.clone());
169169
let _guard = ThreadTracker::tracking(new_tracking_payload);
170170

171-
histogram.observe(1801.0);
171+
histogram.observe(28801.0);
172172

173173
assert_contain_metric(GLOBAL_METRICS_REGISTRY.dump_sample()?, MetricSample {
174174
name: uniq_metric_name.clone(),
@@ -184,7 +184,7 @@ fn test_tracking_scoped_histogram_in_seconds_metrics() -> Result<()> {
184184
}
185185

186186
// untracking assert
187-
histogram.observe(1801.0);
187+
histogram.observe(28801.0);
188188

189189
assert_contain_metric(GLOBAL_METRICS_REGISTRY.dump_sample()?, MetricSample {
190190
name: uniq_metric_name.clone(),
@@ -205,7 +205,7 @@ fn test_tracking_scoped_histogram_in_seconds_metrics() -> Result<()> {
205205
fn test_tracking_scoped_histogram_in_milliseconds_metrics() -> Result<()> {
206206
let uniq_metric_name = GlobalUniqName::unique();
207207
let histogram = register_histogram_in_milliseconds(&uniq_metric_name);
208-
histogram.observe(1800001.0);
208+
histogram.observe(28800001.0);
209209

210210
fn milliseconds_histogram_value(v: f64) -> Vec<HistogramCount> {
211211
BUCKET_MILLISECONDS
@@ -228,7 +228,7 @@ fn test_tracking_scoped_histogram_in_milliseconds_metrics() -> Result<()> {
228228
new_tracking_payload.metrics = Some(scoped_registry.clone());
229229
let _guard = ThreadTracker::tracking(new_tracking_payload);
230230

231-
histogram.observe(1800001.0);
231+
histogram.observe(28800001.0);
232232

233233
assert_contain_metric(GLOBAL_METRICS_REGISTRY.dump_sample()?, MetricSample {
234234
name: uniq_metric_name.clone(),
@@ -244,7 +244,7 @@ fn test_tracking_scoped_histogram_in_milliseconds_metrics() -> Result<()> {
244244
}
245245

246246
// untracking assert
247-
histogram.observe(1800001.0);
247+
histogram.observe(28800001.0);
248248

249249
assert_contain_metric(GLOBAL_METRICS_REGISTRY.dump_sample()?, MetricSample {
250250
name: uniq_metric_name.clone(),

0 commit comments

Comments
ย (0)