Skip to content

Commit

Permalink
format metrics in nice boxes, suggestions in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Aug 18, 2022
1 parent c8a9918 commit 1d6722e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bin/src/ctl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fn print_gauges_and_counts(filtered_metrics: &BTreeMap<String, FilteredData>) {
}

let mut table = Table::new();
table.set_format(*prettytable::format::consts::FORMAT_NO_TITLE);
table.set_format(*prettytable::format::consts::FORMAT_BOX_CHARS);

table.set_titles(Row::new(vec![cell!(""), cell!("gauge"), cell!("count")]));

Expand Down Expand Up @@ -247,7 +247,7 @@ fn print_percentiles(filtered_metrics: &BTreeMap<String, FilteredData>) {
}

let mut percentile_table = Table::new();
percentile_table.set_format(*prettytable::format::consts::FORMAT_NO_TITLE);
percentile_table.set_format(*prettytable::format::consts::FORMAT_BOX_CHARS);

percentile_table.set_titles(Row::new(vec![
cell!("Percentiles"),
Expand Down
14 changes: 8 additions & 6 deletions lib/src/metrics/local_drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,16 @@ pub struct LocalDrain {
/// a prefix to metric keys, usually "sozu-"
pub prefix: String,
pub created: Instant,
/// should be AggregatedMetric
pub cluster_tree: BTreeMap<String, u64>,
pub backend_tree: BTreeMap<String, u64>,
/// metric_name -> metric value
pub proxy_metrics: BTreeMap<String, AggregatedMetric>,
/// keyTABcluster_id -> (metric meta, metric kind)
/// metric_nameTABcluster_id -> (metric meta, metric kind)
/// this is messed up, what would be better is:
/// BTreeMap<cluster_id or backend_id, BTreeMap<metric_name, (MetricMeta, MetricKind, u64)>>
/// and even better:
/// BTreeMap<cluster_id or backend_id, BTreeMap<metric_name, AggregatedMetric>>
cluster_metrics: BTreeMap<String, (MetricMeta, MetricKind)>,
use_tagged_metrics: bool,
origin: String,
Expand Down Expand Up @@ -182,13 +187,10 @@ impl LocalDrain {
}

pub fn dump_process_data(&mut self) -> BTreeMap<String, FilteredData> {
let data: BTreeMap<String, FilteredData> = self
.proxy_metrics
self.proxy_metrics
.iter()
.map(|(key, value)| (key.to_string(), aggregated_to_filtered(value)))
.collect();

data
.collect()
}

pub fn query(&mut self, q: &QueryMetricsType) -> QueryAnswerMetrics {
Expand Down

0 comments on commit 1d6722e

Please sign in to comment.