Crate readings_probe

Source
Expand description

§Instrumentation Probe for Readings

Readings goal is to make process vital metrics intrumentation as easy as possible.

This is the instrumentation library that must be embedded in the client code.

Please refer to the Readings

// this is optional but the cost may be worth it. YMMV. It instruments
// Rust global allocator.
readings_probe::instrumented_allocator!();

fn main() -> readings_probe::ReadingsResult<()> {
    // setup the probe
    let mut probe =
        readings_probe::Probe::new(std::fs::File::create("readings.out").unwrap()).unwrap();

    // We will use an AtomicI64 to communicate a user-defined metrics ("progress") to the probe.
    let progress = probe.register_i64("progress".to_string())?;

    // Starts the probe (1sec i a lot. heartbeat can be realistically set as low as a few millis).
    probe.spawn_heartbeat(std::time::Duration::from_millis(1000))?;

    // do some stuff, update progress
    let percent_done = 12;
    progress.store(percent_done, std::sync::atomic::Ordering::Relaxed);

    // do more stuff, log an event
    probe.log_event("about to get crazy")?;

    // still more stuff, and another event
    probe.log_event("done")?;
    Ok(())
}

Modules§

alloc
allocator instrumentation
global
grobal default probe instance and associated macros This module contains helpers to put a Probe in a global “well-known” place, allowing to instrument deep routines without passing the Probe around the entire stack.

Macros§

instrumented_allocator
Setup global allocator instrumentation, to track rust-managed memory.
wrap_global_allocator
Setup global allocator instrumentation, to track rust-managed memory.

Structs§

OsReadings
Probe
The interface to reading probe.

Enums§

ReadingsError
Reading error enumeration.

Functions§

get_os_readings
Returns metrics from the operating system interface.

Type Aliases§

ReadingsResult
Reading generic Result helper.