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
2 changes: 1 addition & 1 deletion bottlecap/src/lifecycle/invocation/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ mod tests {
total_user_time_ms: 100.0,
total_system_time_ms: 53.0,
total_idle_time_ms: 20.0,
individual_cpu_idle_times: individual_cpu_idle_times,
individual_cpu_idle_times,
});

let uptime_offset = Some(50.0);
Expand Down
3 changes: 2 additions & 1 deletion bottlecap/src/lifecycle/invocation/triggers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ where
pub mod test_utils {
use std::fs;

#[must_use]
pub fn read_json_file(file_name: &str) -> String {
fs::read_to_string(format!("tests/payloads/{}", file_name)).expect("Failed to read file")
fs::read_to_string(format!("tests/payloads/{file_name}")).expect("Failed to read file")
}
}
4 changes: 2 additions & 2 deletions bottlecap/src/metrics/enhanced/lambda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ mod tests {
total_idle_time_ms: 10.0,
individual_cpu_idle_times: individual_cpu_idle_time_offsets,
};
let uptime_offset = 1891100.0;
let uptime_offset = 1_891_100.0;

let mut individual_cpu_idle_times_end = HashMap::new();
individual_cpu_idle_times_end.insert("cpu0".to_string(), 570.0);
Expand All @@ -674,7 +674,7 @@ mod tests {
total_idle_time_ms: 1130.0,
individual_cpu_idle_times: individual_cpu_idle_times_end,
};
let uptime_data = 1891900.0;
let uptime_data = 1_891_900.0;

Lambda::generate_cpu_utilization_enhanced_metrics(
&cpu_offset,
Expand Down
42 changes: 21 additions & 21 deletions bottlecap/src/proc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,39 +189,39 @@ mod tests {
#[allow(clippy::float_cmp)]
fn test_get_network_data() {
let path = "./tests/proc/net/valid_dev";
let network_data_result = get_network_data_from_path(&path);
assert!(!network_data_result.is_err());
let network_data_result = get_network_data_from_path(path);
assert!(network_data_result.is_ok());
let network_data_result = network_data_result.unwrap();
assert_eq!(network_data_result.rx_bytes, 180.0);
assert_eq!(network_data_result.tx_bytes, 254.0);

let path = "./tests/proc/net/invalid_dev_malformed";
let network_data_result = get_network_data_from_path(&path);
let network_data_result = get_network_data_from_path(path);
assert!(network_data_result.is_err());

let path = "./tests/proc/net/invalid_dev_non_numerical_value";
let network_data_result = get_network_data_from_path(&path);
let network_data_result = get_network_data_from_path(path);
assert!(network_data_result.is_err());

let path = "./tests/proc/net/missing_interface_dev";
let network_data_result = get_network_data_from_path(&path);
let network_data_result = get_network_data_from_path(path);
assert!(network_data_result.is_err());

let path = "./tests/proc/net/nonexistent_dev";
let network_data_result = get_network_data_from_path(&path);
let network_data_result = get_network_data_from_path(path);
assert!(network_data_result.is_err());
}

#[test]
#[allow(clippy::float_cmp)]
fn test_get_cpu_data() {
let path = "./tests/proc/stat/valid_stat";
let cpu_data_result = get_cpu_data_from_path(&path);
assert!(!cpu_data_result.is_err());
let cpu_data_result = get_cpu_data_from_path(path);
assert!(cpu_data_result.is_ok());
let cpu_data = cpu_data_result.unwrap();
assert_eq!(cpu_data.total_user_time_ms, 23370.0);
assert_eq!(cpu_data.total_system_time_ms, 1880.0);
assert_eq!(cpu_data.total_idle_time_ms, 178380.0);
assert_eq!(cpu_data.total_idle_time_ms, 178_380.0);
assert_eq!(cpu_data.individual_cpu_idle_times.len(), 2);
assert_eq!(
*cpu_data
Expand All @@ -239,49 +239,49 @@ mod tests {
);

let path = "./tests/proc/stat/invalid_stat_non_numerical_value_1";
let cpu_data_result = get_cpu_data_from_path(&path);
let cpu_data_result = get_cpu_data_from_path(path);
assert!(cpu_data_result.is_err());

let path = "./tests/proc/stat/invalid_stat_non_numerical_value_2";
let cpu_data_result = get_cpu_data_from_path(&path);
let cpu_data_result = get_cpu_data_from_path(path);
assert!(cpu_data_result.is_err());

let path = "./tests/proc/stat/invalid_stat_malformed_first_line";
let cpu_data_result = get_cpu_data_from_path(&path);
let cpu_data_result = get_cpu_data_from_path(path);
assert!(cpu_data_result.is_err());

let path = "./tests/proc/stat/invalid_stat_malformed_per_cpu_line";
let cpu_data_result = get_cpu_data_from_path(&path);
let cpu_data_result = get_cpu_data_from_path(path);
assert!(cpu_data_result.is_err());

let path = "./tests/proc/stat/invalid_stat_missing_cpun_data";
let cpu_data_result = get_cpu_data_from_path(&path);
let cpu_data_result = get_cpu_data_from_path(path);
assert!(cpu_data_result.is_err());

let path = "./tests/proc/stat/nonexistent_stat";
let cpu_data_result = get_cpu_data_from_path(&path);
let cpu_data_result = get_cpu_data_from_path(path);
assert!(cpu_data_result.is_err());
}

#[test]
#[allow(clippy::float_cmp)]
fn test_get_uptime_data() {
let path = "./tests/proc/uptime/valid_uptime";
let uptime_data_result = get_uptime_from_path(&path);
assert!(!uptime_data_result.is_err());
let uptime_data_result = get_uptime_from_path(path);
assert!(uptime_data_result.is_ok());
let uptime_data = uptime_data_result.unwrap();
assert_eq!(uptime_data, 3213103123000.0);
assert_eq!(uptime_data, 3_213_103_123_000.0);

let path = "./tests/proc/uptime/invalid_data_uptime";
let uptime_data_result = get_uptime_from_path(&path);
let uptime_data_result = get_uptime_from_path(path);
assert!(uptime_data_result.is_err());

let path = "./tests/proc/uptime/malformed_uptime";
let uptime_data_result = get_uptime_from_path(&path);
let uptime_data_result = get_uptime_from_path(path);
assert!(uptime_data_result.is_err());

let path = "./tests/proc/uptime/nonexistent_uptime";
let uptime_data_result = get_uptime_from_path(&path);
let uptime_data_result = get_uptime_from_path(path);
assert!(uptime_data_result.is_err());
}
}
21 changes: 21 additions & 0 deletions bottlecap/src/traces/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,24 @@ pub mod stats_processor;
pub mod trace_agent;
pub mod trace_flusher;
pub mod trace_processor;

// URL for a call to the Lambda runtime API. The value may be replaced if `AWS_LAMBDA_RUNTIME_API` is set.
const LAMBDA_RUNTIME_URL_PREFIX: &str = "http://127.0.0.1:9001";

// URL for a call from the Datadog Lambda Library to the Lambda Extension
const LAMBDA_EXTENSION_URL_PREFIX: &str = "http://127.0.0.1:8124";
Comment thread
duncanista marked this conversation as resolved.

// the first part of a URL for a call from Statsd
const LAMBDA_STATSD_URL_PREFIX: &str = "http://127.0.0.1:8125";

// the first part of a URL from the non-routable address for DNS traces
const DNS_NON_ROUTABLE_ADDRESS_URL_PREFIX: &str = "0.0.0.0";

// the first part of a URL from the localhost address for DNS traces
const DNS_LOCAL_HOST_ADDRESS_URL_PREFIX: &str = "127.0.0.1";

// URL from the `_AWS_XRAY_DAEMON_ADDRESS` for DNS traces
const AWS_XRAY_DAEMON_ADDRESS_URL_PREFIX: &str = "169.254.79.129";

// Name of the placeholder invocation span set by Java and Go tracers
const INVOCATION_SPAN_RESOURCE: &str = "dd-tracer-serverless-span";
Comment thread
duncanista marked this conversation as resolved.
Loading