Skip to content
Merged
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
19 changes: 13 additions & 6 deletions bottlecap/src/metrics/enhanced/lambda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,12 @@ impl Lambda {
fd_max: f64,
fd_use: f64,
aggr: &mut std::sync::MutexGuard<Aggregator>,
tags: Option<SortedTags>,
) {
let metric = Metric::new(
constants::FD_MAX_METRIC.into(),
MetricValue::distribution(fd_max),
None,
tags.clone(),
);
if let Err(e) = aggr.insert(metric) {
error!("Failed to insert fd_max metric: {}", e);
Expand All @@ -506,7 +507,7 @@ impl Lambda {
let metric = Metric::new(
constants::FD_USE_METRIC.into(),
MetricValue::distribution(fd_use),
None,
tags,
);
if let Err(e) = aggr.insert(metric) {
error!("Failed to insert fd_use metric: {}", e);
Expand All @@ -518,11 +519,12 @@ impl Lambda {
threads_max: f64,
threads_use: f64,
aggr: &mut std::sync::MutexGuard<Aggregator>,
tags: Option<SortedTags>,
) {
let metric = Metric::new(
constants::THREADS_MAX_METRIC.into(),
MetricValue::distribution(threads_max),
None,
tags.clone(),
);
if let Err(e) = aggr.insert(metric) {
error!("Failed to insert threads_max metric: {}", e);
Expand All @@ -533,7 +535,7 @@ impl Lambda {
let metric = Metric::new(
constants::THREADS_USE_METRIC.into(),
MetricValue::distribution(threads_use),
None,
tags,
);
if let Err(e) = aggr.insert(metric) {
error!("Failed to insert threads_use metric: {}", e);
Expand All @@ -547,6 +549,7 @@ impl Lambda {
}

let aggr = Arc::clone(&self.aggregator);
let tags = self.get_dynamic_value_tags();

tokio::spawn(async move {
// get list of all process ids
Expand All @@ -568,8 +571,8 @@ impl Lambda {
_ = send_metrics.changed() => {
let mut aggr: std::sync::MutexGuard<Aggregator> =
aggr.lock().expect("lock poisoned");
Self::generate_fd_enhanced_metrics(fd_max, fd_use, &mut aggr);
Self::generate_threads_enhanced_metrics(threads_max, threads_use, &mut aggr);
Self::generate_fd_enhanced_metrics(fd_max, fd_use, &mut aggr, tags.clone());
Self::generate_threads_enhanced_metrics(threads_max, threads_use, &mut aggr, tags);
return;
}
// Otherwise keep monitoring file descriptor and thread usage periodically
Expand Down Expand Up @@ -1015,6 +1018,7 @@ mod tests {
fd_max,
fd_use,
&mut lambda.aggregator.lock().expect("lock poisoned"),
None,
);

assert_sketch(&metrics_aggr, constants::FD_MAX_METRIC, 1024.0);
Expand All @@ -1033,6 +1037,7 @@ mod tests {
fd_max,
fd_use,
&mut lambda.aggregator.lock().expect("lock poisoned"),
None,
);

assert_sketch(&metrics_aggr, constants::FD_MAX_METRIC, 1024.0);
Expand All @@ -1055,6 +1060,7 @@ mod tests {
threads_max,
threads_use,
&mut lambda.aggregator.lock().expect("lock poisoned"),
None,
);

assert_sketch(&metrics_aggr, constants::THREADS_MAX_METRIC, 1024.0);
Expand All @@ -1073,6 +1079,7 @@ mod tests {
threads_max,
threads_use,
&mut lambda.aggregator.lock().expect("lock poisoned"),
None,
);

assert_sketch(&metrics_aggr, constants::THREADS_MAX_METRIC, 1024.0);
Expand Down