Skip to content

Commit

Permalink
Merge pull request #74 from hydai/hydai/enable_stat_in_wasmedge
Browse files Browse the repository at this point in the history
  • Loading branch information
Burning1020 authored Sep 9, 2023
2 parents c15b71f + 7185eea commit 7c18d6f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions wasm/src/wasmedge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use containerd_shim::{
error::Error,
io::Stdio,
monitor::{Subject, Topic},
other_error,
other, other_error,
processes::Process,
protos::{cgroups::metrics::Metrics, shim::oci::Options, types::task::ProcessInfo},
ExitSignal,
Expand Down Expand Up @@ -247,10 +247,18 @@ impl ProcessLifecycle<InitProcess> for WasmEdgeInitLifecycle {
))
}

async fn stats(&self, _p: &InitProcess) -> containerd_shim::Result<Metrics> {
Err(Error::Unimplemented(
"exec not supported for wasm containers".to_string(),
))
async fn stats(&self, p: &InitProcess) -> containerd_shim::Result<Metrics> {
debug!("get stats of process {}", p.pid);
if p.pid <= 0 {
return Err(other!(
"failed to collect metrics because init process is {}",
p.pid
));
}
// Because Wasm Applications execute the instructions inside the host Wasm
// Runtime, we should read the metrics from Cgroup for the CPU, memory,
// and filesystem usage.
containerd_shim::cgroup::collect_metrics(p.pid as u32)
}

async fn ps(&self, p: &InitProcess) -> containerd_shim::Result<Vec<ProcessInfo>> {
Expand Down

0 comments on commit 7c18d6f

Please sign in to comment.