Skip to content

Commit 9342644

Browse files
committed
Address review comments
1 parent ce341be commit 9342644

File tree

8 files changed

+115
-119
lines changed

8 files changed

+115
-119
lines changed

lustre-collector/src/fixtures/osd_active.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ osd-ldiskfs.MGS.filesfree=130871
1010
osd-ldiskfs.ai400x2-MDT0000.filesfree=97713887
1111
osd-ldiskfs.ai400x2-OST0000.filesfree=1073740846
1212
osd-ldiskfs.ai400x2-OST0001.filesfree=1073740847
13+
osd-ldiskfs.ai400x2-OST0001.stats=
14+
snapshot_time 1750226041.107629473 secs.nsecs
15+
start_time 1750176720.390243856 secs.nsecs
16+
elapsed_time 49320.717385617 secs.nsecs
17+
get_page 375 samples [usecs] 1 23 2956 28656
18+
cache_access 297 samples [pages] 830 1024 303934
19+
cache_hit 123 samples [pages] 0 1024 303934
20+
cache_miss 297 samples [pages] 830 1024 303934
1321
osd-ldiskfs.MGS.filestotal=131072
1422
osd-ldiskfs.ai400x2-MDT0000.filestotal=97714176
1523
osd-ldiskfs.ai400x2-OST0000.filestotal=1073741824

lustre-collector/src/osd_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ pub(crate) const KBYTES_TOTAL: &str = "kbytestotal";
2626
pub(crate) const FS_TYPE: &str = "fstype";
2727

2828
pub(crate) const BRW_STATS: &str = "brw_stats";
29+
pub(crate) const STATS: &str = "stats";
2930

3031
pub(crate) const QUOTA_ACCT_GRP: &str = "quota_slave.acct_group";
3132
pub(crate) const QUOTA_ACCT_USR: &str = "quota_slave.acct_user";
3233
pub(crate) const QUOTA_ACCT_PRJ: &str = "quota_slave.acct_project";
3334

34-
pub(crate) const STATS: &str = "stats";
35-
3635
pub(crate) fn params() -> Vec<String> {
3736
vec![
3837
format!("osd-*.*.{STATS}"),
@@ -65,6 +64,7 @@ enum OsdStat {
6564
KBytesTotal(u64),
6665
BrwStats(Vec<BrwStats>),
6766
QuotaStats(QuotaStatsOsd),
67+
/// Generic OSD statistics (performance counters, operation counts)
6868
Stats(Vec<Stat>),
6969
}
7070

lustre-collector/src/snapshots/lustre_collector__osd_parser__tests__osd_active_stats.snap

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,83 @@ expression: result
137137
},
138138
),
139139
),
140+
Target(
141+
Stats(
142+
TargetStat {
143+
kind: Ost,
144+
param: Param(
145+
"stats",
146+
),
147+
target: Target(
148+
"ai400x2-OST0001",
149+
),
150+
value: [
151+
Stat {
152+
name: "get_page",
153+
units: "usecs",
154+
samples: 375,
155+
min: Some(
156+
1,
157+
),
158+
max: Some(
159+
23,
160+
),
161+
sum: Some(
162+
2956,
163+
),
164+
sumsquare: Some(
165+
28656,
166+
),
167+
},
168+
Stat {
169+
name: "cache_access",
170+
units: "pages",
171+
samples: 297,
172+
min: Some(
173+
830,
174+
),
175+
max: Some(
176+
1024,
177+
),
178+
sum: Some(
179+
303934,
180+
),
181+
sumsquare: None,
182+
},
183+
Stat {
184+
name: "cache_hit",
185+
units: "pages",
186+
samples: 123,
187+
min: Some(
188+
0,
189+
),
190+
max: Some(
191+
1024,
192+
),
193+
sum: Some(
194+
303934,
195+
),
196+
sumsquare: None,
197+
},
198+
Stat {
199+
name: "cache_miss",
200+
units: "pages",
201+
samples: 297,
202+
min: Some(
203+
830,
204+
),
205+
max: Some(
206+
1024,
207+
),
208+
sum: Some(
209+
303934,
210+
),
211+
sumsquare: None,
212+
},
213+
],
214+
},
215+
),
216+
),
140217
Target(
141218
FilesTotal(
142219
TargetStat {

lustre-collector/src/stats_parser.rs

Lines changed: 11 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ where
133133
#[cfg(test)]
134134
mod tests {
135135
use super::*;
136-
use insta::assert_debug_snapshot;
136+
use insta::{assert_compact_debug_snapshot, assert_debug_snapshot};
137137

138138
#[test]
139139
fn test_name_count_units() {
@@ -142,20 +142,9 @@ mod tests {
142142

143143
let result = name_count_units().parse(x);
144144

145-
assert_debug_snapshot!(
145+
assert_compact_debug_snapshot!(
146146
result,
147-
@r#"
148-
Ok(
149-
(
150-
(
151-
"create",
152-
726,
153-
"reqs",
154-
),
155-
"\n",
156-
),
157-
)
158-
"#
147+
@r#"Ok((("create", 726, "reqs"), "\n"))"#
159148
);
160149
}
161150

@@ -166,29 +155,8 @@ mod tests {
166155

167156
let result = stat().parse(x);
168157

169-
assert_debug_snapshot!(
170-
result, @r#"
171-
Ok(
172-
(
173-
Stat {
174-
name: "cache_miss",
175-
units: "pages",
176-
samples: 21108,
177-
min: Some(
178-
1,
179-
),
180-
max: Some(
181-
1,
182-
),
183-
sum: Some(
184-
21108,
185-
),
186-
sumsquare: None,
187-
},
188-
"",
189-
),
190-
)
191-
"#
158+
assert_compact_debug_snapshot!(
159+
result, @r#"Ok((Stat { name: "cache_miss", units: "pages", samples: 21108, min: Some(1), max: Some(1), sum: Some(21108), sumsquare: None }, ""))"#
192160
);
193161
}
194162

@@ -199,31 +167,8 @@ mod tests {
199167

200168
let result = stat().parse(x);
201169

202-
assert_debug_snapshot!(
203-
result, @r#"
204-
Ok(
205-
(
206-
Stat {
207-
name: "cache_hit",
208-
units: "pages",
209-
samples: 99,
210-
min: Some(
211-
1,
212-
),
213-
max: Some(
214-
1,
215-
),
216-
sum: Some(
217-
99,
218-
),
219-
sumsquare: Some(
220-
10,
221-
),
222-
},
223-
"",
224-
),
225-
)
226-
"#
170+
assert_compact_debug_snapshot!(
171+
result, @r#"Ok((Stat { name: "cache_hit", units: "pages", samples: 99, min: Some(1), max: Some(1), sum: Some(99), sumsquare: Some(10) }, ""))"#
227172
);
228173
}
229174

@@ -234,23 +179,8 @@ mod tests {
234179

235180
let result = stat().parse(x);
236181

237-
assert_debug_snapshot!(
238-
result, @r#"
239-
Ok(
240-
(
241-
Stat {
242-
name: "cache_hit",
243-
units: "pages",
244-
samples: 123,
245-
min: None,
246-
max: None,
247-
sum: None,
248-
sumsquare: None,
249-
},
250-
"",
251-
),
252-
)
253-
"#
182+
assert_compact_debug_snapshot!(
183+
result, @r#"Ok((Stat { name: "cache_hit", units: "pages", samples: 123, min: None, max: None, sum: None, sumsquare: None }, ""))"#
254184
);
255185
}
256186

@@ -261,32 +191,9 @@ mod tests {
261191

262192
let result = stat().parse(x);
263193

264-
assert_debug_snapshot!(
194+
assert_compact_debug_snapshot!(
265195
result,
266-
@r#"
267-
Ok(
268-
(
269-
Stat {
270-
name: "obd_ping",
271-
units: "usec",
272-
samples: 1108,
273-
min: Some(
274-
15,
275-
),
276-
max: Some(
277-
72,
278-
),
279-
sum: Some(
280-
47014,
281-
),
282-
sumsquare: Some(
283-
2156132,
284-
),
285-
},
286-
"",
287-
),
288-
)
289-
"#
196+
@r#"Ok((Stat { name: "obd_ping", units: "usec", samples: 1108, min: Some(15), max: Some(72), sum: Some(47014), sumsquare: Some(2156132) }, ""))"#
290197

291198
);
292199
}

lustrefs-exporter/fixtures/stats.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,7 +2998,7 @@
29982998
"sumsquare": 28656
29992999
},
30003000
{
3001-
"name": "cache_total",
3001+
"name": "cache_access",
30023002
"units": "pages",
30033003
"samples": 297,
30043004
"min": 830,
@@ -3007,7 +3007,7 @@
30073007
"sumsquare": null
30083008
},
30093009
{
3010-
"name": "cache_access",
3010+
"name": "cache_miss",
30113011
"units": "pages",
30123012
"samples": 297,
30133013
"min": 830,
@@ -3016,12 +3016,12 @@
30163016
"sumsquare": null
30173017
},
30183018
{
3019-
"name": "cache_miss",
3019+
"name": "cache_hit",
30203020
"units": "pages",
3021-
"samples": 297,
3021+
"samples": 2810,
30223022
"min": 830,
3023-
"max": 1024,
3024-
"sum": 303934,
3023+
"max": 2956,
3024+
"sum": 28656,
30253025
"sumsquare": null
30263026
},
30273027
{

lustrefs-exporter/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ pub mod tests {
147147
// These metrics are ignored for the comparison with the previous implementation
148148
// since they are new and not present in the previous implementation.
149149
const IGNORED_METRICS: &[&str] = &[
150+
"lustre_cache_hit_total",
150151
"lustre_cache_access_total",
151152
"lustre_cache_miss_total",
152153
"lustre_get_page_total",

lustrefs-exporter/src/snapshots/lustrefs_exporter__tests__stats_otel.snap

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,13 @@ lustre_stats_time_total{component="mdt",operation="unlink",target="ai400x2-MDT00
837837
# HELP lustre_get_page_total The total number of times the linux page cache was used.
838838
# TYPE lustre_get_page_total counter
839839
lustre_get_page_total{component="ost",operation="get_page",target="exatest-OST0003"} 375
840-
# HELP lustre_cache_access_total The total number cache accesses.
840+
# HELP lustre_cache_access_total The total number of cache accesses.
841841
# TYPE lustre_cache_access_total counter
842842
lustre_cache_access_total{component="ost",operation="cache_access",target="exatest-OST0003"} 297
843-
# HELP lustre_cache_miss_total The total number cache misses.
843+
# HELP lustre_cache_hit_total The total number of cache hits.
844+
# TYPE lustre_cache_hit_total counter
845+
lustre_cache_hit_total{component="ost",operation="cache_hit",target="exatest-OST0003"} 2810
846+
# HELP lustre_cache_miss_total The total number of cache misses.
844847
# TYPE lustre_cache_miss_total counter
845848
lustre_cache_miss_total{component="ost",operation="cache_miss",target="exatest-OST0003"} 297
846849
# HELP lustre_many_credits_total The total number of times lustre hit too many credits.

lustrefs-exporter/src/stats.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,19 @@ impl StatsMetrics {
197197

198198
registry.register_without_auto_suffix(
199199
"lustre_cache_access_total",
200-
"The total number cache accesses",
200+
"The total number of cache accesses",
201201
self.cache_access_total.clone(),
202202
);
203203

204204
registry.register_without_auto_suffix(
205205
"lustre_cache_hit_total",
206-
"The total of cache hits",
206+
"The total number of cache hits",
207207
self.cache_hit_total.clone(),
208208
);
209209

210210
registry.register_without_auto_suffix(
211211
"lustre_cache_miss_total",
212-
"The total number cache misses",
212+
"The total number of cache misses",
213213
self.cache_miss_total.clone(),
214214
);
215215

@@ -293,15 +293,15 @@ pub fn build_ost_stats(stats: &[Stat], target: &Target, metrics: &mut StatsMetri
293293
}
294294
}
295295
"get_page" => {
296-
let write_labels = vec![
296+
let get_page_labels = vec![
297297
("component", kind.to_prom_label().to_string()),
298298
("operation", "get_page".into()),
299299
("target", target.deref().to_string()),
300300
];
301301

302302
metrics
303303
.get_page_total
304-
.get_or_create(&write_labels)
304+
.get_or_create(&get_page_labels)
305305
.inc_by(s.samples);
306306
}
307307

0 commit comments

Comments
 (0)