Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move kstat-sampler self-stat timeseries to TOML #6033

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 6 additions & 25 deletions oximeter/instruments/src/kstat/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,13 @@ use tokio::time::Sleep;
// The `KstatSampler` generates some statistics about its own operation, mostly
// for surfacing failures to collect and dropped samples.
mod self_stats {
oximeter::use_timeseries!("kstat-sampler.toml");
use super::BTreeMap;
use super::Cumulative;
use super::TargetId;

/// Information identifying this kstat sampler.
#[derive(Debug, oximeter::Target)]
pub struct KstatSampler {
/// The hostname (or zonename) of the host machine.
pub hostname: String,
}

/// The total number of samples dropped for a single target.
#[derive(Debug, oximeter::Metric)]
pub struct SamplesDropped {
/// The ID of the target being tracked.
pub target_id: u64,
/// The name of the target being tracked.
pub target_name: String,
pub datum: Cumulative<u64>,
}

/// The cumulative number of expired targets.
#[derive(Debug, oximeter::Metric)]
pub struct ExpiredTargets {
pub datum: Cumulative<u64>,
}
pub use kstat_sampler::ExpiredTargets;
pub use kstat_sampler::KstatSampler;
pub use kstat_sampler::SamplesDropped;

#[derive(Debug)]
pub struct SelfStats {
Expand All @@ -85,7 +66,7 @@ mod self_stats {
impl SelfStats {
pub fn new(hostname: String) -> Self {
Self {
target: KstatSampler { hostname },
target: KstatSampler { hostname: hostname.into() },
drops: BTreeMap::new(),
expired: ExpiredTargets { datum: Cumulative::new(0) },
}
Expand Down Expand Up @@ -797,7 +778,7 @@ impl KstatSamplerWorker {
*drops += n_overflow_samples as u64;
let metric = self_stats::SamplesDropped {
target_id: target_id.0,
target_name,
target_name: target_name.into(),
datum: *drops,
};
let sample = match Sample::new(&stats.target, &metric) {
Expand Down
42 changes: 42 additions & 0 deletions oximeter/oximeter/schema/kstat-sampler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
format_version = 1

[target]
name = "kstat_sampler"
description = "A software object sampling kernel statistics"
authz_scope = "fleet"
versions = [
{ version = 1, fields = [ "hostname" ] },
]

[[metrics]]
name = "samples_dropped"
description = "Total number of samples dropped for a single tracked target"
units = "count"
datum_type = "cumulative_u64"
versions = [
{ added_in = 1, fields = [ "target_id", "target_name" ] }
]

[[metrics]]
name = "expired_targets"
description = """\
Total number of targets that have expired. Targets may expire \
after either a limited number of unsuccessful sampling attempts, \
or after a duration of unsuccessful sampling."""
units = "count"
datum_type = "cumulative_u64"
versions = [
{ added_in = 1, fields = [ ] }
]

[fields.hostname]
type = "string"
description = "The hostname (or zonename) of the machine hosting the sampler"

[fields.target_id]
type = "u64"
description = "The unique ID of the target being tracked"

[fields.target_name]
type = "string"
description = "The name of the target being tracked"
Loading