Skip to content

Commit

Permalink
Add LDLM stats (#20)
Browse files Browse the repository at this point in the history
* Add LDLM stats

* Apply suggestions from code review

Co-authored-by: Joe Grund <jgrund@whamcloud.io>

* Use published crate

---------

Co-authored-by: Joe Grund <jgrund@whamcloud.io>
  • Loading branch information
RDruon and jgrund authored Jul 6, 2023
1 parent 1be9055 commit 948c9e7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
pub mod brw_stats;
pub mod jobstats;
pub mod lnet;
pub mod service;
pub mod stats;

use brw_stats::build_target_stats;
use lnet::build_lnet_stats;
use lustre_collector::{LNetStat, LNetStatGlobal, Record, TargetStat, TargetVariant};
use num_traits::Num;
use prometheus_exporter_base::{prelude::*, Yes};
use service::build_service_stats;
use std::{collections::BTreeMap, fmt, ops::Deref, time::Duration};

#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -123,6 +125,9 @@ pub fn build_lustre_stats(output: Vec<Record>, time: Duration) -> String {
lustre_collector::Record::Target(x) => {
build_target_stats(x, &mut stats_map, time);
}
lustre_collector::Record::LustreService(x) => {
build_service_stats(x, &mut stats_map, time);
}
}
}

Expand Down
49 changes: 49 additions & 0 deletions src/service.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use crate::{Metric, StatsMapExt};
use lustre_collector::LustreServiceStats;
use prometheus_exporter_base::prelude::*;
use std::{collections::BTreeMap, ops::Deref, time::Duration};

static LDLM_CANCELD_STATS_SAMPLES: Metric = Metric {
name: "lustre_ldlm_canceld_stats",
help: "Gives information about LDLM Canceld service.",
r#type: MetricType::Counter,
};

static LDLM_CBD_STATS_SAMPLES: Metric = Metric {
name: "lustre_ldlm_cbd_stats",
help: "Gives information about LDLM Callback service.",
r#type: MetricType::Counter,
};

pub fn build_service_stats(
x: LustreServiceStats,
stats_map: &mut BTreeMap<&'static str, PrometheusMetric<'static>>,
time: Duration,
) {
match x {
LustreServiceStats::LdlmCanceld(xs) => {
for s in xs {
stats_map
.get_mut_metric(LDLM_CANCELD_STATS_SAMPLES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("operation", s.name.deref())
.with_value(s.samples)
.with_timestamp(time.as_millis()),
);
}
}
LustreServiceStats::LdlmCbd(xs) => {
for s in xs {
stats_map
.get_mut_metric(LDLM_CBD_STATS_SAMPLES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("operation", s.name.deref())
.with_value(s.samples)
.with_timestamp(time.as_millis()),
);
}
}
};
}

0 comments on commit 948c9e7

Please sign in to comment.