Skip to content
Open
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
53 changes: 44 additions & 9 deletions lading/src/observer.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -31,11 +31,46 @@
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),

Check failure on line 40 in lading/src/observer.rs

View workflow job for this annotation

GitHub Actions / Rust Actions (Check/Fmt/Clippy) (macos-latest, check)

failed to resolve: use of unresolved module or unlinked crate `linux`

Check failure on line 40 in lading/src/observer.rs

View workflow job for this annotation

GitHub Actions / Rust Actions (Check/Fmt/Clippy) (macos-latest, clippy)

failed to resolve: use of unresolved module or unlinked crate `linux`
}

/// 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())

Check failure on line 49 in lading/src/observer.rs

View workflow job for this annotation

GitHub Actions / Rust Actions (Check/Fmt/Clippy) (macos-latest, check)

failed to resolve: use of unresolved module or unlinked crate `linux`

Check failure on line 49 in lading/src/observer.rs

View workflow job for this annotation

GitHub Actions / Rust Actions (Check/Fmt/Clippy) (macos-latest, check)

failed to resolve: use of unresolved module or unlinked crate `linux`

Check failure on line 49 in lading/src/observer.rs

View workflow job for this annotation

GitHub Actions / Rust Actions (Check/Fmt/Clippy) (macos-latest, clippy)

failed to resolve: use of unresolved module or unlinked crate `linux`
}
}

#[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.
Expand Down
13 changes: 13 additions & 0 deletions lading/src/observer/linux.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
//! 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;
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 {
Expand Down
Loading