Skip to content

Commit dca2dd1

Browse files
authored
add missing tags to new metrics (#456)
1 parent 0b851a6 commit dca2dd1

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

bottlecap/src/metrics/enhanced/lambda.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,12 @@ impl Lambda {
491491
fd_max: f64,
492492
fd_use: f64,
493493
aggr: &mut std::sync::MutexGuard<Aggregator>,
494+
tags: Option<SortedTags>,
494495
) {
495496
let metric = Metric::new(
496497
constants::FD_MAX_METRIC.into(),
497498
MetricValue::distribution(fd_max),
498-
None,
499+
tags.clone(),
499500
);
500501
if let Err(e) = aggr.insert(metric) {
501502
error!("Failed to insert fd_max metric: {}", e);
@@ -506,7 +507,7 @@ impl Lambda {
506507
let metric = Metric::new(
507508
constants::FD_USE_METRIC.into(),
508509
MetricValue::distribution(fd_use),
509-
None,
510+
tags,
510511
);
511512
if let Err(e) = aggr.insert(metric) {
512513
error!("Failed to insert fd_use metric: {}", e);
@@ -518,11 +519,12 @@ impl Lambda {
518519
threads_max: f64,
519520
threads_use: f64,
520521
aggr: &mut std::sync::MutexGuard<Aggregator>,
522+
tags: Option<SortedTags>,
521523
) {
522524
let metric = Metric::new(
523525
constants::THREADS_MAX_METRIC.into(),
524526
MetricValue::distribution(threads_max),
525-
None,
527+
tags.clone(),
526528
);
527529
if let Err(e) = aggr.insert(metric) {
528530
error!("Failed to insert threads_max metric: {}", e);
@@ -533,7 +535,7 @@ impl Lambda {
533535
let metric = Metric::new(
534536
constants::THREADS_USE_METRIC.into(),
535537
MetricValue::distribution(threads_use),
536-
None,
538+
tags,
537539
);
538540
if let Err(e) = aggr.insert(metric) {
539541
error!("Failed to insert threads_use metric: {}", e);
@@ -547,6 +549,7 @@ impl Lambda {
547549
}
548550

549551
let aggr = Arc::clone(&self.aggregator);
552+
let tags = self.get_dynamic_value_tags();
550553

551554
tokio::spawn(async move {
552555
// get list of all process ids
@@ -568,8 +571,8 @@ impl Lambda {
568571
_ = send_metrics.changed() => {
569572
let mut aggr: std::sync::MutexGuard<Aggregator> =
570573
aggr.lock().expect("lock poisoned");
571-
Self::generate_fd_enhanced_metrics(fd_max, fd_use, &mut aggr);
572-
Self::generate_threads_enhanced_metrics(threads_max, threads_use, &mut aggr);
574+
Self::generate_fd_enhanced_metrics(fd_max, fd_use, &mut aggr, tags.clone());
575+
Self::generate_threads_enhanced_metrics(threads_max, threads_use, &mut aggr, tags);
573576
return;
574577
}
575578
// Otherwise keep monitoring file descriptor and thread usage periodically
@@ -1015,6 +1018,7 @@ mod tests {
10151018
fd_max,
10161019
fd_use,
10171020
&mut lambda.aggregator.lock().expect("lock poisoned"),
1021+
None,
10181022
);
10191023

10201024
assert_sketch(&metrics_aggr, constants::FD_MAX_METRIC, 1024.0);
@@ -1033,6 +1037,7 @@ mod tests {
10331037
fd_max,
10341038
fd_use,
10351039
&mut lambda.aggregator.lock().expect("lock poisoned"),
1040+
None,
10361041
);
10371042

10381043
assert_sketch(&metrics_aggr, constants::FD_MAX_METRIC, 1024.0);
@@ -1055,6 +1060,7 @@ mod tests {
10551060
threads_max,
10561061
threads_use,
10571062
&mut lambda.aggregator.lock().expect("lock poisoned"),
1063+
None,
10581064
);
10591065

10601066
assert_sketch(&metrics_aggr, constants::THREADS_MAX_METRIC, 1024.0);
@@ -1073,6 +1079,7 @@ mod tests {
10731079
threads_max,
10741080
threads_use,
10751081
&mut lambda.aggregator.lock().expect("lock poisoned"),
1082+
None,
10761083
);
10771084

10781085
assert_sketch(&metrics_aggr, constants::THREADS_MAX_METRIC, 1024.0);

0 commit comments

Comments
 (0)