Skip to content

Commit 4cf5ab1

Browse files
apollo_dashboard: reorder infra row panels per request types
1 parent 7cccff6 commit 4cf5ab1

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

crates/apollo_dashboard/src/dashboard.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ mod dashboard_test;
2626

2727
pub const HISTOGRAM_QUANTILES: &[f64] = &[0.50, 0.95];
2828
pub const HISTOGRAM_TIME_RANGE: &str = "5m";
29+
const INFRA_ROW_TITLE_SUFFIX: &str = "Infra";
2930

3031
// TODO(Tsabary): split this entire module into sub modules.
3132

@@ -628,7 +629,14 @@ fn get_infra_server_panels(
628629
get_request_type_panels(&labeled_metrics, "server")
629630
}
630631

631-
pub(crate) fn get_component_infra_row(row_name: &'static str, metrics: &InfraMetrics) -> Row {
632+
pub(crate) fn get_component_infra_row(row_name: impl ToString, metrics: &InfraMetrics) -> Row {
633+
let mut panels: Vec<Panel> = Vec::new();
634+
// Add the general infra panels.
635+
panels.extend(UnlabeledPanels::from(metrics.get_local_client_metrics()).0);
636+
panels.extend(UnlabeledPanels::from(metrics.get_remote_client_metrics()).0);
637+
panels.extend(UnlabeledPanels::from(metrics.get_local_server_metrics()).0);
638+
panels.extend(UnlabeledPanels::from(metrics.get_remote_server_metrics()).0);
639+
632640
let labeled_client_panels = get_infra_client_panels(
633641
metrics.get_local_client_metrics(),
634642
metrics.get_remote_client_metrics(),
@@ -637,16 +645,22 @@ pub(crate) fn get_component_infra_row(row_name: &'static str, metrics: &InfraMet
637645
metrics.get_local_server_metrics(),
638646
metrics.get_remote_server_metrics(),
639647
);
648+
assert!(
649+
labeled_client_panels.len() == labeled_server_panels.len(),
650+
"Number of labeled client and server panels must be equal, as there's a single panel per \
651+
request type."
652+
);
653+
// Add the client and server panels for each request type, next to each other.
654+
for (request_type_client_panel, request_type_server_panel) in
655+
labeled_client_panels.into_iter().zip(labeled_server_panels.into_iter())
656+
{
657+
panels.push(request_type_client_panel);
658+
panels.push(request_type_server_panel);
659+
}
640660

641-
let mut panels: Vec<Panel> = Vec::new();
642-
panels.extend(UnlabeledPanels::from(metrics.get_local_client_metrics()).0);
643-
panels.extend(UnlabeledPanels::from(metrics.get_remote_client_metrics()).0);
644-
panels.extend(UnlabeledPanels::from(metrics.get_local_server_metrics()).0);
645-
panels.extend(UnlabeledPanels::from(metrics.get_remote_server_metrics()).0);
646-
panels.extend(labeled_client_panels);
647-
panels.extend(labeled_server_panels);
648-
649-
Row::new(row_name, panels)
661+
// Annotate the row name with infra row the suffix.
662+
let modified_row_name = format!("{} {INFRA_ROW_TITLE_SUFFIX}", row_name.to_string());
663+
Row::new(modified_row_name, panels)
650664
}
651665

652666
/// Returns a PromQL expression that calculates the time since the last increase of the given

0 commit comments

Comments
 (0)