Skip to content

Commit

Permalink
Merge branch 'main' into jhe-view-columns
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Feb 2, 2023
2 parents 42740e0 + 894ec26 commit aaeb75b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/common/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ metrics = "0.20.1"
metrics-exporter-prometheus = { version = "0.11.0", default-features = false }
once_cell = "1.15.0"
parking_lot = "0.12.1"
procfs = "0.12.0"
prometheus-parse = "0.2.3"
serde = { workspace = true }
tracing = "0.1.36"

[target.'cfg(target_os = "linux")'.dependencies]
procfs = "0.12.0"

[dev-dependencies]
anyhow = { workspace = true }

Expand Down
10 changes: 7 additions & 3 deletions src/common/metrics/src/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use std::collections::HashMap;
use common_exception::ErrorCode;
use common_exception::Result;
use metrics_exporter_prometheus::PrometheusHandle;
use procfs::ProcResult;

#[derive(Debug)]
pub struct MetricSample {
Expand Down Expand Up @@ -109,10 +108,15 @@ pub fn dump_metric_samples(handle: PrometheusHandle) -> Result<Vec<MetricSample>
Ok(samples)
}

pub fn dump_proc_stats() -> ProcResult<Vec<MetricSample>> {
#[cfg(not(target_os = "linux"))]
pub fn dump_proc_stats() -> Result<Vec<MetricSample>> {
Ok(vec![])
}

#[cfg(target_os = "linux")]
pub fn dump_proc_stats() -> procfs::ProcResult<Vec<MetricSample>> {
let me = procfs::process::Process::myself()?;
let io = me.io()?;

// ❯ cat /proc/thread-self/io
// rchar: 4092
// wchar: 8
Expand Down

0 comments on commit aaeb75b

Please sign in to comment.