Skip to content

Commit

Permalink
update docs, process test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTeng2001 committed Nov 20, 2024
1 parent dfe5e7d commit f45b762
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sources/host_metrics/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ impl HostMetrics {

#[cfg(test)]
mod tests {
use crate::sources::host_metrics::tests::count_tag;

use super::super::{HostMetrics, HostMetricsConfig, MetricsBuffer};

#[tokio::test]
Expand All @@ -68,5 +70,10 @@ mod tests {
assert!(!metrics
.iter()
.any(|metric| !metric.name().starts_with("process_")));

// They should all have the required tag
assert_eq!(count_tag(&metrics, "pid"), metrics.len());
assert_eq!(count_tag(&metrics, "name"), metrics.len());
assert_eq!(count_tag(&metrics, "command"), metrics.len());
}
}
17 changes: 17 additions & 0 deletions website/cue/reference/components/sources/host_metrics.cue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ components: sources: host_metrics: {
type: "gauge"
}

// Host process
process_runtime: _host & _process_counter & {description: "The process uptime."}
process_cpu_usage: _host & _process_gauge & {description: "The process CPU usage."}
process_memory_usage: _host & _process_gauge & {description: "The process memory usage."}

// Host cgroups
cgroup_cpu_usage_seconds_total: _host & _cgroup_cpu & {description: "The total amount CPU time used by this cgroup and its descendants, in seconds."}
cgroup_cpu_user_seconds_total: _host & _cgroup_cpu & {description: "The total amount of CPU time spent by this cgroup in user space, in seconds."}
Expand Down Expand Up @@ -256,5 +261,17 @@ components: sources: host_metrics: {
}
}
_network_nomac: _network_gauge & {relevant_when: "OS is not macOS"}
_process_counter: {
type: "counter"
tags: _host_metrics_tags & {
collector: examples: ["process"]
}
}
_process_gauge: {
type: "gauge"
tags: _host_metrics_tags & {
collector: examples: ["process"]
}
}
}
}

0 comments on commit f45b762

Please sign in to comment.