Skip to content

Commit eeb8c83

Browse files
authored
ref(autoscaling): add prefix to autoscaling metrics (#4530)
This PR adds the `relay_` prefix to all produced metrics so they can be specifically queried. The metrics names are quite generic and with the prefix they are easier to find and use
1 parent 9f0cb41 commit eeb8c83

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

relay-server/src/endpoints/autoscaling.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ fn to_prometheus_string(data: &AutoscalingData) -> String {
2828

2929
append_data_row(&mut result, "memory_usage", data.memory_usage);
3030
append_data_row(&mut result, "up", data.up);
31-
append_data_row(&mut result, "item_count", data.item_count);
32-
append_data_row(&mut result, "total_size", data.total_size);
31+
append_data_row(&mut result, "spool_item_count", data.item_count);
32+
append_data_row(&mut result, "spool_total_size", data.total_size);
3333
result
3434
}
3535

3636
fn append_data_row(result: &mut String, label: &str, data: impl Display) {
37+
// Metrics are automatically prefixed with "relay_"
38+
result.push_str("relay_");
3739
result.push_str(label);
3840
result.push(' ');
3941
result.push_str(&data.to_string());
@@ -55,7 +57,11 @@ mod test {
5557
let result = super::to_prometheus_string(&data);
5658
assert_eq!(
5759
result,
58-
"memory_usage 0.75\nup 1\nitem_count 10\ntotal_size 30\n"
60+
r#"relay_memory_usage 0.75
61+
relay_up 1
62+
relay_spool_item_count 10
63+
relay_spool_total_size 30
64+
"#
5965
);
6066
}
6167
}

relay-server/src/services/buffer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ mod tests {
905905
addr.addr().send(EnvelopeBuffer::Push(envelope.clone()));
906906
}
907907

908-
tokio::time::sleep(Duration::from_millis(100)).await;
908+
tokio::time::sleep(Duration::from_millis(1100)).await;
909909

910910
assert_eq!(addr.metrics.item_count.load(Ordering::Relaxed), 10);
911911
}

tests/integration/test_autoscaling.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_basic_autoscaling_endpoint(mini_sentry, relay):
2121
response = relay.get("/api/relay/autoscaling/")
2222
parsed = parse_prometheus(response.text)
2323
assert response.status_code == 200
24-
assert int(parsed["up"]) == 1
24+
assert int(parsed["relay_up"]) == 1
2525

2626

2727
def test_sqlite_spooling_metrics(mini_sentry, relay):
@@ -49,9 +49,9 @@ def test_sqlite_spooling_metrics(mini_sentry, relay):
4949
response = relay.get("/api/relay/autoscaling/")
5050
assert response.status_code == 200
5151
body = parse_prometheus(response.text)
52-
assert int(body["item_count"]) == 200
53-
assert int(body["up"]) == 1
54-
assert int(body["total_size"]) > 30000
52+
assert int(body["relay_spool_item_count"]) == 200
53+
assert int(body["relay_up"]) == 1
54+
assert int(body["relay_spool_total_size"]) > 30000
5555

5656

5757
def test_memory_spooling_metrics(mini_sentry, relay):
@@ -69,6 +69,6 @@ def test_memory_spooling_metrics(mini_sentry, relay):
6969
response = relay.get("/api/relay/autoscaling/")
7070
assert response.status_code == 200
7171
body = parse_prometheus(response.text)
72-
assert int(body["item_count"]) == 200
73-
assert int(body["up"]) == 1
74-
assert int(body["total_size"]) == 0
72+
assert int(body["relay_spool_item_count"]) == 200
73+
assert int(body["relay_up"]) == 1
74+
assert int(body["relay_spool_total_size"]) == 0

0 commit comments

Comments
 (0)