Skip to content
Draft
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
4 changes: 4 additions & 0 deletions lading/src/bin/captool/analyze/jsonl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ pub(crate) fn list_metrics(lines: &[Line]) -> Vec<MetricInfo> {
/// Returns statistics grouped by label set (context).
#[must_use]
#[expect(clippy::cast_precision_loss)]
#[expect(
clippy::expect_used,
reason = "context_map and fetch_indices are populated together by the same loop; a missing fetch_indices entry indicates a programming error in the caller"
)]
pub(crate) fn analyze_metric(
lines: &[Line],
metric_name: &str,
Expand Down
4 changes: 4 additions & 0 deletions lading/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ impl Server {
/// # Panics
///
/// None are known.
#[expect(
clippy::expect_used,
reason = "child.id() returning Some always fits in i32 on supported platforms; a failure here indicates a platform invariant violation"
)]
pub async fn run(self, mut pid_snd: TargetPidReceiver) -> Result<ExitStatus, Error> {
let target_pid = pid_snd.recv().await?;
drop(pid_snd);
Expand Down
4 changes: 4 additions & 0 deletions lading/src/neper/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ pub(crate) fn join_all<T>(handles: Vec<JoinHandle<T>>) -> Result<Vec<T>, ()> {
}

/// Spawn a named OS thread running `f`.
#[expect(
clippy::expect_used,
reason = "thread::Builder::spawn fails only when the OS cannot allocate a thread; this is an unrecoverable resource exhaustion"
)]
pub(crate) fn spawn_named<F, T>(name: &str, f: F) -> JoinHandle<T>
where
F: FnOnce() -> T + Send + 'static,
Expand Down
4 changes: 4 additions & 0 deletions lading/src/observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ impl Server {
clippy::cast_possible_truncation,
clippy::cast_sign_loss
)]
#[expect(
clippy::expect_used,
reason = "the observer requires the target PID to begin sampling; a missing PID at this point indicates an unrecoverable orchestration failure"
)]
#[cfg(target_os = "linux")]
pub async fn run(
self,
Expand Down
4 changes: 4 additions & 0 deletions lading/src/observer/linux/cgroup/v2/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ impl Sampler {
}

// Read cgroup CPU data and calculate a percentage of usage.
#[expect(
clippy::expect_used,
reason = "cpu.stat lines from the kernel are guaranteed by the cgroup v2 interface to have key/value pairs; deviation indicates a kernel ABI break"
)]
pub(crate) async fn poll(
&mut self,
group_prefix: &Path,
Expand Down
8 changes: 8 additions & 0 deletions lading/src/observer/linux/procfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ impl Sampler {
clippy::cast_possible_truncation,
clippy::cast_possible_wrap
)]
#[expect(
clippy::expect_used,
reason = "process_info is populated for every pid before handle_process is called; a missing entry here indicates a programming error in the sampler driver"
)]
async fn handle_process(
&mut self,
process: Process,
Expand Down Expand Up @@ -375,6 +379,10 @@ async fn proc_comm(pid: i32) -> Result<String, Error> {

/// Collect the 'name' of the process. This is pulled from `/proc/<pid>/exe` and
/// we take the last part of that, like posix `top` does.
#[expect(
clippy::expect_used,
reason = "Linux exe symlink targets are valid UTF-8 paths in all real-world cases; non-UTF-8 indicates a non-standard filesystem encoding"
)]
async fn proc_exe(pid: i32) -> Result<String, Error> {
let exe_path = format!("/proc/{pid}/exe");
let exe = tokio::fs::read_link(&exe_path).await?;
Expand Down
4 changes: 4 additions & 0 deletions lading/src/observer/linux/procfs/memory/smaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ impl Regions {
map.into_iter().collect()
}

#[expect(
clippy::expect_used,
reason = "compile-time-constant regex literal; failure to compile is a programming error caught in tests"
)]
fn into_region_strs(contents: &str) -> Vec<&str> {
let mut str_regions = Vec::new();
// Split the smaps file into regions
Expand Down
8 changes: 8 additions & 0 deletions lading/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ impl Server {

/// Watch a container running elsewhere on the system. lading will report an
/// error if the container exits before the test completes.
#[expect(
clippy::expect_used,
reason = "container PIDs fit in i32 on supported platforms; a failure indicates a platform invariant violation"
)]
async fn watch_container(
config: DockerConfig,
pid_snd: TargetPidSender,
Expand Down Expand Up @@ -374,6 +378,10 @@ impl Server {

/// Execute a binary target. lading will attempt to gracefully terminate the
/// process after the test has completed.
#[expect(
clippy::expect_used,
reason = "child PIDs returned by tokio::process::Command fit in i32 on supported platforms; a failure indicates a platform invariant violation"
)]
async fn execute_binary(
config: BinaryConfig,
pid_snd: TargetPidSender,
Expand Down
4 changes: 4 additions & 0 deletions lading/src/target_metrics/expvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ impl Expvar {
/// # Panics
///
/// None are known.
#[expect(
clippy::expect_used,
reason = "reqwest::ClientBuilder::build fails only on TLS backend setup; an unrecoverable bootstrap failure"
)]
pub(crate) async fn run(self) -> Result<(), Error> {
info!("Expvar target metrics scraper running, but waiting for warmup to complete");
self.experiment_started.recv().await; // block until experimental lading_signal::Watcher entered
Expand Down
8 changes: 8 additions & 0 deletions lading/src/target_metrics/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ use tracing::{error, info, trace, warn};

// Regex to match Prometheus label pairs: label_name="label_value"
// The value can be empty (e.g., label="")
#[expect(
clippy::expect_used,
reason = "compile-time-constant regex literal; failure to compile is a programming error caught in tests"
)]
static LABEL_REGEX: Lazy<Regex> =
Lazy::new(|| Regex::new(r#"(\w+)="([^"]*)""#).expect("Failed to compile label regex"));

Expand Down Expand Up @@ -179,6 +183,10 @@ pub(crate) async fn scrape_metrics(
clippy::cast_possible_truncation,
clippy::cast_sign_loss
)]
#[expect(
clippy::expect_used,
reason = "FIXME: this is an ad-hoc Prometheus parser that panics on malformed input; reported parse failures should surface as recoverable errors. Tracked for follow-up."
)]
pub(crate) fn parse_prometheus_metrics(
text: &str,
tags: Option<&FxHashMap<String, String>>,
Expand Down
Loading