From 044bfd0ab3dc3b53217c4f3e735680d2d7e39b65 Mon Sep 17 00:00:00 2001 From: "Geoffrey M. Oxberry" Date: Thu, 13 Nov 2025 19:25:16 -0800 Subject: [PATCH 1/2] observer: prep docs to expose observer as optional I think the quickest way to make an observer optional in Lading is to add an enumerated type specifying the variants of observer that are available. While the Linux observer is currently the only observer variant available, it may be desirable to add others in the future. Compared to a boolean option, using an enumerated type more easily enables later extension of the observer concept. Signed-off-by: Geoffrey M. Oxberry --- lading/src/observer.rs | 14 +++++++------- lading/src/observer/linux.rs | 6 ++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lading/src/observer.rs b/lading/src/observer.rs index 6d1f3495f..9c816fb6a 100644 --- a/lading/src/observer.rs +++ b/lading/src/observer.rs @@ -1,12 +1,12 @@ //! Manage the target observer //! -//! The interogation that lading does of the target sub-process is intentionally -//! limited to in-process concerns, for the most part. The 'inspector' does -//! allow for a sub-process to do out-of-band inspection of the target but -//! cannot incorporate whatever it's doing into the capture data that lading -//! produces. This observer, on Linux, looks up the target process in procfs and -//! writes out key details about memory and CPU consumption into the capture -//! data. On non-Linux systems the observer, if enabled, will emit a warning. +//! The interrogation that lading does of the target sub-process is +//! intentionally limited to in-process concerns, for the most part. The +//! 'inspector' does allow for a sub-process to do out-of-band inspection of the +//! target but cannot incorporate whatever it's doing into the capture data that +//! lading produces. In contrast, an observer does out-of-band inspection of the +//! target that incorporates information it collects into capture data that +//! lading produces. use std::io; diff --git a/lading/src/observer/linux.rs b/lading/src/observer/linux.rs index 78dc5826f..29a0d9312 100644 --- a/lading/src/observer/linux.rs +++ b/lading/src/observer/linux.rs @@ -1,3 +1,9 @@ +//! Linux observer +//! +//! On Linux, this observer looks up the target process in procfs and writes +//! out key details about memory and CPU consumption into the capture data. On +//! non-Linux systems the observer, if enabled, will emit a warning. + mod cgroup; mod procfs; mod utils; From 2076d35a9a1e7a4b82f6c3c95cf4656dfe8b53bc Mon Sep 17 00:00:00 2001 From: "Geoffrey M. Oxberry" Date: Thu, 13 Nov 2025 20:40:19 -0800 Subject: [PATCH 2/2] observer: foreshadow making it part of lading.yaml I'd eventually like to make the observer an optional part of Lading enabled by adding `observer: linux` to `lading.yaml` files. In order to do that, I need to add some types to define a Linux observer variant and to store its variant-specific configuration. This commit adds those types. The `core::Default` implementations written in this commit are intended to be temporary to preserve the existing `lading.yaml` semantics that treat the observer as mandatory when `lading` is run with a target. Signed-off-by: Geoffrey M. Oxberry --- lading/src/observer.rs | 39 ++++++++++++++++++++++++++++++++++-- lading/src/observer/linux.rs | 7 +++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/lading/src/observer.rs b/lading/src/observer.rs index 9c816fb6a..17700a6fd 100644 --- a/lading/src/observer.rs +++ b/lading/src/observer.rs @@ -31,11 +31,46 @@ pub enum Error { Linux(#[from] linux::Error), } -#[derive(Debug, Deserialize, Clone, Copy, Default, PartialEq, Eq)] +#[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq)] #[serde(rename_all = "snake_case")] #[serde(deny_unknown_fields)] /// Configuration for [`Server`] -pub struct Config {} +pub enum Inner { + /// A Linux observer. See [`crate::observer::linux::Config`] for details. + Linux(linux::Config), +} + +/// Temporary implementation to foreshadow how observer config will be exposed in +/// `lading.yaml`. This scaffolding will be removed once the +/// `#[serde(skip_deserializing)]` decorator is removed from +/// [`crate::config::Config`]. +impl Default for Inner { + fn default() -> Self { + Self::Linux(linux::Config::default()) + } +} + +#[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +#[serde(deny_unknown_fields)] +/// Configuration for [`Server`] +pub struct Config { + /// The generator config + #[serde(flatten)] + pub inner: Inner, +} + +/// Temporary implementation to foreshadow how observer config will be exposed in +/// `lading.yaml`. This scaffolding will be removed once the +/// `#[serde(skip_deserializing)]` decorator is removed from +/// [`crate::config::Config`]. +impl Default for Config { + fn default() -> Self { + Self { + inner: Inner::default(), + } + } +} #[derive(Debug)] /// The inspector sub-process server. diff --git a/lading/src/observer/linux.rs b/lading/src/observer/linux.rs index 29a0d9312..69bf1bed9 100644 --- a/lading/src/observer/linux.rs +++ b/lading/src/observer/linux.rs @@ -9,8 +9,15 @@ mod procfs; mod utils; mod wss; +use serde::Deserialize; use tracing::{error, warn}; +#[derive(Debug, Deserialize, Clone, Copy, Default, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +#[serde(deny_unknown_fields)] +/// Configuration for Linux observer +pub struct Config {} + #[derive(thiserror::Error, Debug)] /// Errors produced by functions in this module pub enum Error {