Skip to content

Commit 81bd75c

Browse files
asaf-swclaude
andauthored
apollo_dashboard: delete dead code (#14086)
Remove `AlertLogicalOp::Or`, `PanelType::BarGauge`, `ThresholdMode::Percentage`, and `Panel::with_percentage_thresholds` — none of these are referenced anywhere in the codebase (all carried `#[allow(dead_code)]` with TODO notes). Also remove stale `#[allow(dead_code)]` annotations from `show_percent_change` and `with_log_comment`, which are actively used in panels and tests. Co-authored-by: Claude <noreply@anthropic.com>
1 parent f8ac910 commit 81bd75c

3 files changed

Lines changed: 0 additions & 32 deletions

File tree

crates/apollo_dashboard/src/alerts.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ pub(crate) enum AlertComparisonOp {
108108
#[serde(rename_all = "snake_case")]
109109
pub(crate) enum AlertLogicalOp {
110110
And,
111-
// TODO(Tsabary): remove the `allow(dead_code)` once this variant is used.
112-
#[allow(dead_code)]
113-
Or,
114111
}
115112

116113
/// Defines the condition to trigger the alert.

crates/apollo_dashboard/src/dashboard_test.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,13 @@ fn test_ratio_time_series() {
9696
);
9797
let panel = Panel::ratio_time_series("y", "y", &metric_1, &[&metric_2], duration);
9898
assert_eq!(panel.exprs, vec![expected]);
99-
assert!(panel.extra.show_percent_change.is_none());
10099
assert!(panel.extra.log_query.is_none());
101100
}
102101

103102
#[test]
104103
fn test_extra_params() {
105104
let panel_with_extra_params = Panel::new("x", "x", "y".to_string(), PanelType::Stat)
106105
.with_unit(Unit::Bytes)
107-
.show_percent_change()
108106
.with_log_query("Query")
109107
.with_absolute_thresholds(vec![
110108
("green", None),
@@ -114,7 +112,6 @@ fn test_extra_params() {
114112
.with_legends(vec!["a"]);
115113

116114
assert_eq!(panel_with_extra_params.extra.unit, Some(Unit::Bytes));
117-
assert_eq!(panel_with_extra_params.extra.show_percent_change, Some(true));
118115
assert_eq!(panel_with_extra_params.extra.log_query, Some("\"Query\"".to_string()));
119116
assert_eq!(
120117
panel_with_extra_params.extra.thresholds,
@@ -131,7 +128,6 @@ fn test_extra_params() {
131128

132129
let panel_without_extra_params = Panel::new("x", "x", "y".to_string(), PanelType::Stat);
133130
assert!(panel_without_extra_params.extra.unit.is_none());
134-
assert!(panel_without_extra_params.extra.show_percent_change.is_none());
135131
assert!(panel_without_extra_params.extra.log_query.is_none());
136132
assert!(panel_without_extra_params.extra.thresholds.is_none());
137133
assert!(panel_without_extra_params.extra.legends.is_none());

crates/apollo_dashboard/src/panel.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ pub(crate) const HISTOGRAM_TIME_RANGE: &str = "5m";
2020
pub(crate) enum PanelType {
2121
Stat,
2222
TimeSeries,
23-
#[allow(dead_code)] // TODO(Ron): use BarGauge in panels
24-
BarGauge,
2523
PieChart,
2624
}
2725

@@ -60,10 +58,7 @@ impl Serialize for Unit {
6058
#[derive(Clone, Debug, PartialEq, Serialize)]
6159
#[serde(rename_all = "lowercase")]
6260
pub enum ThresholdMode {
63-
#[allow(dead_code)] // TODO(Ron): use in panels
6461
Absolute,
65-
#[allow(dead_code)] // TODO(Ron): use in panels
66-
Percentage,
6762
}
6863

6964
#[derive(Clone, Debug, PartialEq, Serialize)]
@@ -82,7 +77,6 @@ pub struct Thresholds {
8277
#[derive(Debug, Default, Clone, PartialEq, Serialize)]
8378
pub struct ExtraParams {
8479
pub unit: Option<Unit>,
85-
pub show_percent_change: Option<bool>,
8680
pub log_query: Option<String>,
8781
pub log_comment: Option<String>,
8882
pub thresholds: Option<Thresholds>,
@@ -155,18 +149,6 @@ impl Panel {
155149
self.extra.unit = Some(unit);
156150
self
157151
}
158-
#[allow(dead_code)] // TODO(Ron): use in panels
159-
pub fn show_percent_change(mut self) -> Self {
160-
assert_eq!(
161-
self.panel_type,
162-
PanelType::Stat,
163-
"show_percent_change is only supported on Stat panels; got {:?}",
164-
self.panel_type
165-
);
166-
self.extra.show_percent_change = Some(true);
167-
self
168-
}
169-
170152
fn quote_if_missing(s: &str) -> String {
171153
if s.contains('"') { s.to_string() } else { format!("\"{}\"", s) }
172154
}
@@ -176,7 +158,6 @@ impl Panel {
176158
self.extra.log_query = Some(query);
177159
self
178160
}
179-
#[allow(dead_code)] // TODO(Ron): use in panels
180161
pub fn with_log_comment(mut self, log_comment: impl Into<String>) -> Self {
181162
let comment = Self::quote_if_missing(&log_comment.into());
182163
self.extra.log_comment = Some(format!("-- {}", comment));
@@ -256,12 +237,6 @@ impl Panel {
256237
self.with_thresholds(ThresholdMode::Absolute, steps)
257238
}
258239

259-
#[allow(dead_code)] // TODO(Ron): use in panels
260-
// Percentage means relative to min and max.
261-
pub fn with_percentage_thresholds(self, steps: Vec<(impl ToString, Option<f64>)>) -> Self {
262-
self.with_thresholds(ThresholdMode::Percentage, steps)
263-
}
264-
265240
pub(crate) fn ratio_time_series(
266241
name: &str,
267242
description: &str,

0 commit comments

Comments
 (0)