Autoscale the graph vertically
This commit is contained in:
parent
4760ff97e0
commit
21e4cf042e
|
@ -116,6 +116,20 @@ pub struct ScalarWindow {
|
||||||
pub y_axis: RangeInclusive<f64>,
|
pub y_axis: RangeInclusive<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ScalarWindow {
|
||||||
|
pub fn summarise_in_place(&mut self) {
|
||||||
|
let mut min_point = f64::INFINITY;
|
||||||
|
let mut max_point = f64::NEG_INFINITY;
|
||||||
|
|
||||||
|
for (_, point) in self.points.iter() {
|
||||||
|
min_point = min_point.min(*point);
|
||||||
|
max_point = max_point.max(*point);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.y_axis = min_point..=max_point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct MetricsLogReadingRequester {
|
pub struct MetricsLogReadingRequester {
|
||||||
pub shared: Arc<MetricsLogReadingShared>,
|
pub shared: Arc<MetricsLogReadingShared>,
|
||||||
pub tx: Sender<MetricsLogReaderMessage>,
|
pub tx: Sender<MetricsLogReaderMessage>,
|
||||||
|
@ -529,6 +543,13 @@ impl<R: Read + Seek> MetricsLogReaderManager<R> {
|
||||||
.insert(metric_id, unsummarised_histogram.summarise());
|
.insert(metric_id, unsummarised_histogram.summarise());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (metric_id, gauge) in metrics_window.gauges.iter_mut() {
|
||||||
|
gauge.summarise_in_place();
|
||||||
|
}
|
||||||
|
for (metric_id, counter) in metrics_window.counters.iter_mut() {
|
||||||
|
counter.summarise_in_place();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(metrics_window)
|
Ok(metrics_window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue