Skip to content

Commit bac1249

Browse files
Emit metrics for record_progress endpoint
Previously we were only tracking the worker time, not the endpoint.
1 parent d4e2717 commit bac1249

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/server/routes/agent.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use http::Response;
1212
use hyper::Body;
1313
use std::collections::HashMap;
1414
use std::sync::{Arc, Condvar, Mutex};
15+
use std::time::Instant;
1516
use warp::{self, Filter, Rejection};
1617

1718
#[derive(Deserialize)]
@@ -214,7 +215,7 @@ impl RecordProgressThread {
214215

215216
metrics
216217
.crater_endpoint_time
217-
.with_label_values(&["record_progress"])
218+
.with_label_values(&["record_progress_worker"])
218219
.observe(start.elapsed().as_secs_f64());
219220
}
220221
}));
@@ -298,14 +299,23 @@ fn endpoint_record_progress(
298299
data: Arc<Data>,
299300
_auth: AuthDetails,
300301
) -> Fallible<Response<Body>> {
301-
match data.record_progress_worker.queue.try_send(result) {
302+
let start = Instant::now();
303+
304+
let ret = match data.record_progress_worker.queue.try_send(result) {
302305
Ok(()) => Ok(ApiResponse::Success { result: true }.into_response()?),
303306
Err(crossbeam_channel::TrySendError::Full(_)) => {
304307
data.metrics.crater_bounced_record_progress.inc_by(1);
305308
Ok(ApiResponse::<()>::SlowDown.into_response()?)
306309
}
307310
Err(crossbeam_channel::TrySendError::Disconnected(_)) => unreachable!(),
308-
}
311+
};
312+
313+
data.metrics
314+
.crater_endpoint_time
315+
.with_label_values(&["record_progress_endpoint"])
316+
.observe(start.elapsed().as_secs_f64());
317+
318+
ret
309319
}
310320

311321
fn endpoint_heartbeat(data: Arc<Data>, auth: AuthDetails) -> Fallible<Response<Body>> {

0 commit comments

Comments
 (0)