Skip to content
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
22 changes: 20 additions & 2 deletions bottlecap/src/lifecycle/invocation/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ use crate::{
span_inferrer::SpanInferrer, tag_span_from_value,
},
metrics::enhanced::lambda::{EnhancedMetricData, Lambda as EnhancedMetrics},
proc::{self, CPUData, NetworkData},
tags::provider,
proc::{
self,
constants::{ETC_PATH, PROC_PATH},
CPUData, NetworkData,
},
tags::{lambda::tags::resolve_runtime_from_proc, provider},
telemetry::events::{ReportMetrics, Status},
traces::{
context::SpanContext,
Expand Down Expand Up @@ -63,6 +67,7 @@ pub struct Processor {
aws_config: AwsConfig,
// Flag to determine if a tracer was detected
tracer_detected: bool,
runtime: Option<String>,
config: Arc<config::Config>,
}

Expand Down Expand Up @@ -91,6 +96,7 @@ impl Processor {
enhanced_metrics: EnhancedMetrics::new(metrics_aggregator, Arc::clone(&config)),
aws_config: aws_config.clone(),
tracer_detected: false,
runtime: None,
config: Arc::clone(&config),
}
}
Expand Down Expand Up @@ -166,6 +172,11 @@ impl Processor {
} else {
cold_start = true;
}

// Resolve runtime only once
let runtime = resolve_runtime_from_proc(PROC_PATH, ETC_PATH);
self.enhanced_metrics.set_runtime_tag(&runtime);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely needed tho

self.runtime = Some(runtime);
}

if proactive_initialization {
Expand All @@ -174,6 +185,13 @@ impl Processor {
proactive_initialization.to_string(),
);
}

if let Some(runtime) = &self.runtime {
self.span
.meta
.insert(String::from("runtime"), runtime.to_string());
}
Comment on lines +188 to +193
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we actually need this, it looks like previous versions have the runtime tag in spans, but not sure if this is done in backend or tracer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do need it


self.span
.meta
.insert(String::from("cold_start"), cold_start.to_string());
Expand Down
8 changes: 7 additions & 1 deletion bottlecap/src/metrics/enhanced/lambda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Lambda {
}
}

/// Set the dynamic value tags that are not available at compile time
/// Set the init tags in `dynamic_value_tags`
pub fn set_init_tags(&mut self, proactive_initialization: bool, cold_start: bool) {
self.dynamic_value_tags.remove("cold_start");
self.dynamic_value_tags.remove("proactive_initialization");
Expand All @@ -52,6 +52,12 @@ impl Lambda {
}
}

/// Sets the runtime tag in `dynamic_value_tags`
pub fn set_runtime_tag(&mut self, runtime: &str) {
self.dynamic_value_tags
.insert(String::from("runtime"), runtime.to_string());
}

fn get_dynamic_value_tags(&self) -> Option<SortedTags> {
let vec_tags: Vec<String> = self
.dynamic_value_tags
Expand Down
1 change: 1 addition & 0 deletions bottlecap/src/proc/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub const PROC_NET_DEV_PATH: &str = "/proc/net/dev";
pub const PROC_STAT_PATH: &str = "/proc/stat";
pub const PROC_UPTIME_PATH: &str = "/proc/uptime";
pub const PROC_PATH: &str = "/proc";
pub const ETC_PATH: &str = "/etc";

pub const LAMDBA_NETWORK_INTERFACE: &str = "vinternal_1";
pub const LAMBDA_FILE_DESCRIPTORS_DEFAULT_LIMIT: f64 = 1024.0;
Expand Down
3 changes: 1 addition & 2 deletions bottlecap/src/tags/lambda/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ fn tags_from_env(
tags_map
}

#[allow(dead_code)] // keeping this logic for when async runtime resolution will be supported
fn resolve_runtime_from_proc(proc_path: &str, fallback_provided_al_path: &str) -> String {
pub fn resolve_runtime_from_proc(proc_path: &str, fallback_provided_al_path: &str) -> String {
let start = Instant::now();
match fs::read_dir(proc_path) {
Ok(proc_dir) => {
Expand Down
Loading