Skip to content

Commit 53bd9ef

Browse files
authored
ref(autoscaling): expose different metric name (#4618)
This PR exposes the same values as `relay_utilization` using the key `relay_service_utilization`. With the addition of new `relay_..._utilization` metrics, the service related metric `relay_utilization` is not very descriptive and can lead to confusion. To enable a smooth transition away from the generic name, we will 1. expose the new metric name 2. change everything that relies on the old name to the new name 3. remove the exposure of the old name
1 parent 18ac746 commit 53bd9ef

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

relay-server/src/endpoints/autoscaling.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,22 @@ fn to_prometheus_string(data: &AutoscalingData) -> String {
3333
append_data_row(&mut result, "spool_total_size", data.total_size, &[]);
3434
for utilization in &data.services_metrics {
3535
let service_name = extract_service_name(utilization.0);
36+
// Expose both names temporarily so we can phase out `utilization` in favor
37+
// of `service_utilization`
3638
append_data_row(
3739
&mut result,
3840
"utilization",
3941
utilization.1,
4042
&[("relay_service", service_name)],
4143
);
44+
append_data_row(
45+
&mut result,
46+
"service_utilization",
47+
utilization.1,
48+
&[("relay_service", service_name)],
49+
);
4250
}
51+
4352
append_data_row(
4453
&mut result,
4554
"worker_pool_utilization",
@@ -151,7 +160,9 @@ relay_up 1
151160
relay_spool_item_count 10
152161
relay_spool_total_size 30
153162
relay_utilization{relay_service="test"} 10
163+
relay_service_utilization{relay_service="test"} 10
154164
relay_utilization{relay_service="envelope"} 50
165+
relay_service_utilization{relay_service="envelope"} 50
155166
relay_worker_pool_utilization 61
156167
relay_runtime_utilization 41
157168
"#

tests/integration/test_autoscaling.py

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import tempfile
88
from time import sleep
99

10+
import pytest
11+
1012

1113
def parse_prometheus(input_string):
1214
result = {}
@@ -74,34 +76,20 @@ def test_memory_spooling_metrics(mini_sentry, relay):
7476
assert int(body["relay_spool_total_size"]) == 0
7577

7678

77-
def test_service_utilization_metrics(mini_sentry, relay):
78-
relay = relay(mini_sentry)
79-
80-
response = relay.get("/api/relay/autoscaling/")
81-
parsed = parse_prometheus(response.text)
82-
assert response.status_code == 200
83-
84-
assert int(parsed["relay_up"]) == 1
85-
assert (
86-
0 <= int(parsed['relay_utilization{relay_service="AggregatorService"}']) <= 100
87-
)
88-
89-
90-
def test_pool_utilization(mini_sentry, relay):
91-
relay = relay(mini_sentry)
92-
93-
response = relay.get("/api/relay/autoscaling/")
94-
parsed = parse_prometheus(response.text)
95-
assert response.status_code == 200
96-
97-
assert 0 <= int(parsed["relay_worker_pool_utilization"]) <= 100
98-
99-
100-
def test_runtime_utilization(mini_sentry, relay):
79+
@pytest.mark.parametrize(
80+
"metric_name",
81+
(
82+
'relay_utilization{relay_service="AggregatorService"}',
83+
'relay_service_utilization{relay_service="AggregatorService"}',
84+
"relay_worker_pool_utilization",
85+
"relay_runtime_utilization",
86+
),
87+
)
88+
def test_service_utilization_metrics(mini_sentry, relay, metric_name):
10189
relay = relay(mini_sentry)
10290

10391
response = relay.get("/api/relay/autoscaling/")
10492
parsed = parse_prometheus(response.text)
10593
assert response.status_code == 200
10694

107-
assert 0 <= int(parsed["relay_runtime_utilization"]) <= 100
95+
assert 0 <= int(parsed[metric_name]) <= 100

0 commit comments

Comments
 (0)