Skip to content

Commit 2617504

Browse files
authored
fix(console): remove histogram minimum count (#424)
The sparklines histogram used to visualize poll times and scheduled times renders a legend for both axes. On the horizontal axis, it displays the durations for the minimum and maximum buckets. On the vertical axis, it displays the bucket count minimum and maximums. Unfortunately, the minimum values for each axis are places together, which can be confusing: ```text ╭Poll Times Histogram─────────────────────────────────╮ │46█ │ │ █ │ │ █ │ │ █ │ │ █ ▂ │ │ █▁█▇▃▁▁ ▁ ▁▁ ▁ │ │ 031.23µs 7.11ms│ ╰─────────────────────────────────────────────────────╯ ^|----| │ ╰─ This is the minimum bucket duration value ╰── This is the minimum count ``` This can be confusing because it looks like there is an erroneous leading zero on the minimum bucket duration. If the minimum value is not zero, then the vertical axis minimum is updated, but the bottom of the sparkline still represents zero. This sitaution is unlikely, I had to add a fixed value to the bucket counts to generate the histogram below. ```text ╭Poll Times Histogram─────────────────────────────────╮ │32██ │ │ ██▇ ▁ ▁ ▁ ▁ ▁ │ │ ███▇▆▆▆█▇▆▇▆▆▆▆▆▆▆▇▆▆▆▆█▆▇▆█▆▇█▆█▇▇▇▆▇▇▆▇▆▆▇▆▆▆▆▆▇ │ │ ██████████████████████████████████████████████████ │ │ ██████████████████████████████████████████████████ │ │ ██████████████████████████████████████████████████ │ │2033.79µs 536.58µs │ ╰─────────────────────────────────────────────────────╯ ^^|----| │ ╰─ This is the minimum bucket duration value ╰── This is the minimum count ``` This is probably misleading. This change removes the minimum label on the vertical axis entirely. This removes the confusion around the "erroneous" leading zero and since the bottom of the graph is always zero anyway, it should be clear to users without having to add the label. The resulting histogram looks like: ```text ╭Poll Times Histogram─────────────────────────────────╮ │27 █▄ │ │ ██ │ │ ██ │ │ ██ │ │ ██▂ │ │ ▃███▃▁ ▁ ▁▃ ▃▃▃▁▃▅▁▃ ▃▃▃▃▃▁▁▁ ▁ ▁ ▁│ │ 28.93µs 811.01µs │ ╰─────────────────────────────────────────────────────╯ ```
1 parent cbf6f56 commit 2617504

File tree

1 file changed

+0
-15
lines changed

1 file changed

+0
-15
lines changed

tokio-console/src/view/mini_histogram.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ pub(crate) struct HistogramMetadata {
3939
pub(crate) min_value: u64,
4040
/// The value of the bucket with the greatest quantity
4141
pub(crate) max_bucket: u64,
42-
/// The value of the bucket with the smallest quantity
43-
pub(crate) min_bucket: u64,
4442
/// Number of high outliers, if any
4543
pub(crate) high_outliers: u64,
4644
pub(crate) highest_outlier: Option<Duration>,
@@ -87,7 +85,6 @@ impl<'a> Widget for MiniHistogram<'a> {
8785
};
8886

8987
let max_qty_label = metadata.max_bucket.to_string();
90-
let min_qty_label = metadata.min_bucket.to_string();
9188
let max_record_label = format!(
9289
"{:.prec$?}",
9390
Duration::from_nanos(metadata.max_value),
@@ -107,7 +104,6 @@ impl<'a> Widget for MiniHistogram<'a> {
107104
max_record_label,
108105
min_record_label,
109106
max_qty_label,
110-
min_qty_label,
111107
);
112108

113109
let legend_height = if metadata.high_outliers > 0 { 2 } else { 1 };
@@ -229,7 +225,6 @@ fn render_legend(
229225
max_record_label: String,
230226
min_record_label: String,
231227
max_qty_label: String,
232-
min_qty_label: String,
233228
) {
234229
// If there are outliers, display a note
235230
let labels_pos = if metadata.high_outliers > 0 {
@@ -253,14 +248,6 @@ fn render_legend(
253248

254249
// top left: max quantity
255250
buf.set_string(area.left(), area.top(), &max_qty_label, Style::default());
256-
// bottom left: 0 aligned to right
257-
let zero_label = format!("{:>width$}", &min_qty_label, width = max_qty_label.len());
258-
buf.set_string(
259-
area.left(),
260-
area.bottom() - labels_pos,
261-
&zero_label,
262-
Style::default(),
263-
);
264251
// bottom left below the chart: min time
265252
buf.set_string(
266253
area.left() + max_qty_label.len() as u16,
@@ -311,14 +298,12 @@ fn chart_data(histogram: &DurationHistogram, width: u16) -> (Vec<u64>, Histogram
311298
Vec::new()
312299
};
313300
let max_bucket = data.iter().max().copied().unwrap_or_default();
314-
let min_bucket = data.iter().min().copied().unwrap_or_default();
315301
(
316302
data,
317303
HistogramMetadata {
318304
max_value: histogram.max(),
319305
min_value: histogram.min(),
320306
max_bucket,
321-
min_bucket,
322307
high_outliers,
323308
highest_outlier,
324309
},

0 commit comments

Comments
 (0)