Skip to content

Commit

Permalink
feat: collect memory size in bytes and the number of logical cores
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Feb 26, 2024
1 parent 807bac2 commit 18a2209
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ pub struct WorkerHeartbeat {
pub identifier: WorkerIdentifier,
/// The git commit of buildit
pub git_commit: Option<String>,
/// Total memory in bytes
pub memory_bytes: u64,
/// Number of logical cores
pub logical_cores: u64,
}

pub async fn ensure_job_queue(queue_name: &str, channel: &Channel) -> anyhow::Result<Queue> {
Expand Down
2 changes: 2 additions & 0 deletions worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ futures = "0.3.30"
gethostname = "0.4.3"
lapin = "2.3.1"
log = "0.4.20"
num_cpus = "1.16.0"
once_cell = "1.19.0"
reqwest = "0.11.24"
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
sysinfo = "0.30.5"
tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread", "process", "sync", "fs"] }

[build-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions worker/src/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub async fn heartbeat_worker_inner(args: &Args) -> anyhow::Result<()> {
pid: std::process::id(),
},
git_commit: option_env!("VERGEN_GIT_DESCRIBE").map(String::from),
memory_bytes: sysinfo::System::new_all().total_memory(),
logical_cores: num_cpus::get() as u64,
})
.unwrap(),
BasicProperties::default(),
Expand Down

0 comments on commit 18a2209

Please sign in to comment.