Skip to content

Commit 2051538

Browse files
committed
Auto merge of #711 - Mark-Simulacrum:track-worker-count, r=Mark-Simulacrum
Fix worker metrics
2 parents 8491684 + 8d6f5fc commit 2051538

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/server/agents.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl Agents {
9999
let mut guard = self.current_workers.lock().unwrap();
100100
guard.retain(|_, (_, timestamp)| {
101101
// It's been 10 minutes since we heard from this worker, drop it from our active list.
102-
timestamp.elapsed() > std::time::Duration::from_secs(60 * 10)
102+
timestamp.elapsed() < std::time::Duration::from_secs(60 * 10)
103103
});
104104
guard.len()
105105
}

src/server/metrics.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::experiments::{Assignee, Experiment};
33
use crate::prelude::*;
44
use crate::server::agents::Agent;
55
use chrono::{DateTime, Utc};
6-
use prometheus::{HistogramVec, IntCounter, IntCounterVec, IntGauge, IntGaugeVec};
6+
use prometheus::{Histogram, HistogramVec, IntCounter, IntCounterVec, IntGauge, IntGaugeVec};
77

88
const JOBS_METRIC: &str = "crater_completed_jobs_total";
99
const AGENT_WORK_METRIC: &str = "crater_agent_supposed_to_work";
@@ -21,6 +21,7 @@ pub struct Metrics {
2121
crater_last_crates_update: IntGauge,
2222
pub crater_endpoint_time: HistogramVec,
2323
crater_worker_count: IntGauge,
24+
pub result_log_size: Histogram,
2425
}
2526

2627
impl Metrics {
@@ -47,6 +48,11 @@ impl Metrics {
4748
.buckets(prometheus::exponential_buckets(0.05, 1.2, 25).unwrap()),
4849
&["endpoint"]
4950
)?;
51+
let result_log_size = prometheus::register_histogram!(
52+
"crater_log_length",
53+
"payload size in bytes",
54+
prometheus::exponential_buckets(4096.0, 1.28, 30)?
55+
)?;
5056

5157
let crater_worker_count = prometheus::opts!(WORKER_COUNT, "number of active workers");
5258
let crater_worker_count = prometheus::register_int_gauge!(crater_worker_count)?;
@@ -59,6 +65,7 @@ impl Metrics {
5965
crater_last_crates_update,
6066
crater_endpoint_time,
6167
crater_worker_count,
68+
result_log_size,
6269
})
6370
}
6471

src/server/routes/agent.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ fn endpoint_record_progress(
303303
) -> Fallible<Response<Body>> {
304304
let start = Instant::now();
305305

306+
data.metrics
307+
.result_log_size
308+
.observe(result.data.result.log.len() as f64);
309+
306310
let ret = match data.record_progress_worker.queue.try_send(result) {
307311
Ok(()) => Ok(ApiResponse::Success { result: true }.into_response()?),
308312
Err(crossbeam_channel::TrySendError::Full(_)) => {

0 commit comments

Comments
 (0)