proxy: change is cold start to enum (#6948)

## Problem

Actually it's good idea to distinguish between cases when it's a cold
start, but we took the compute from the pool

## Summary of changes

Updated to enum.
This commit is contained in:
Anna Khanova
2024-03-04 13:31:28 +04:00
committed by GitHub
parent 8dc7dc79dd
commit 3114be034a
3 changed files with 55 additions and 42 deletions

View File

@@ -93,7 +93,7 @@ struct RequestData {
/// Or if we make it to proxy_pass
success: bool,
/// Indicates if the cplane started the new compute node for this request.
is_cold_start: Option<bool>,
cold_start_info: Option<String>,
/// Tracks time from session start (HTTP request/libpq TCP handshake)
/// Through to success/failure
duration_us: u64,
@@ -121,7 +121,10 @@ impl From<RequestMonitoring> for RequestData {
region: value.region,
error: value.error_kind.as_ref().map(|e| e.to_metric_label()),
success: value.success,
is_cold_start: value.is_cold_start,
cold_start_info: value
.cold_start_info
.as_ref()
.map(|x| serde_json::to_string(x).unwrap_or_default()),
duration_us: SystemTime::from(value.first_packet)
.elapsed()
.unwrap_or_default()
@@ -455,7 +458,7 @@ mod tests {
region: "us-east-1",
error: None,
success: rng.gen(),
is_cold_start: Some(true),
cold_start_info: Some("no".into()),
duration_us: rng.gen_range(0..30_000_000),
}
}
@@ -525,16 +528,16 @@ mod tests {
assert_eq!(
file_stats,
[
(1315032, 3, 6000),
(1315025, 3, 6000),
(1315085, 3, 6000),
(1315042, 3, 6000),
(1315172, 3, 6000),
(1315014, 3, 6000),
(1314806, 3, 6000),
(1315042, 3, 6000),
(438563, 1, 2000)
],
(1314406, 3, 6000),
(1314399, 3, 6000),
(1314459, 3, 6000),
(1314416, 3, 6000),
(1314546, 3, 6000),
(1314388, 3, 6000),
(1314180, 3, 6000),
(1314416, 3, 6000),
(438359, 1, 2000)
]
);
tmpdir.close().unwrap();
@@ -563,12 +566,12 @@ mod tests {
assert_eq!(
file_stats,
[
(1220433, 5, 10000),
(1226583, 5, 10000),
(1228377, 5, 10000),
(1227739, 5, 10000),
(1219017, 5, 10000)
],
(1220668, 5, 10000),
(1226818, 5, 10000),
(1228612, 5, 10000),
(1227974, 5, 10000),
(1219252, 5, 10000)
]
);
tmpdir.close().unwrap();
@@ -599,12 +602,12 @@ mod tests {
assert_eq!(
file_stats,
[
(1206080, 5, 10000),
(1205811, 5, 10000),
(1206104, 5, 10000),
(1206092, 5, 10000),
(1206347, 5, 10000)
],
(1206315, 5, 10000),
(1206046, 5, 10000),
(1206339, 5, 10000),
(1206327, 5, 10000),
(1206582, 5, 10000)
]
);
tmpdir.close().unwrap();
@@ -628,16 +631,16 @@ mod tests {
assert_eq!(
file_stats,
[
(1315032, 3, 6000),
(1315025, 3, 6000),
(1315085, 3, 6000),
(1315042, 3, 6000),
(1315172, 3, 6000),
(1315014, 3, 6000),
(1314806, 3, 6000),
(1315042, 3, 6000),
(438563, 1, 2000)
],
(1314406, 3, 6000),
(1314399, 3, 6000),
(1314459, 3, 6000),
(1314416, 3, 6000),
(1314546, 3, 6000),
(1314388, 3, 6000),
(1314180, 3, 6000),
(1314416, 3, 6000),
(438359, 1, 2000)
]
);
tmpdir.close().unwrap();
@@ -673,7 +676,7 @@ mod tests {
// files are smaller than the size threshold, but they took too long to fill so were flushed early
assert_eq!(
file_stats,
[(659129, 2, 3001), (658842, 2, 3000), (658638, 2, 2999)],
[(658837, 2, 3001), (658551, 2, 3000), (658347, 2, 2999)]
);
tmpdir.close().unwrap();