pub struct Report { /* private fields */ }Expand description
A human- and machine-readable report about observed occurrences of events.
For human-readable output, use the Display trait implementation. This is intended
for writing to a terminal and uses only the basic ASCII character set.
For machine-readable output, inspect report contents via the provided methods.
Implementations§
Source§impl Report
impl Report
Sourcepub fn collect() -> Self
pub fn collect() -> Self
Generates a report by collecting all metrics for all events.
§Example
use nm::{Event, Report};
thread_local! {
static TEST_EVENT: Event = Event::builder()
.name("test_event")
.build();
}
// Observe some events first
TEST_EVENT.with(|e| e.observe_once());
let report = Report::collect();
println!("{}", report);§Panics
Panics if the same event is registered on different threads with a different configuration.
Sourcepub fn events(&self) -> impl Iterator<Item = &EventMetrics>
pub fn events(&self) -> impl Iterator<Item = &EventMetrics>
Iterates through all the events in the report, allowing access to their metrics.
§Example
use nm::{Event, Report};
thread_local! {
static TEST_EVENT: Event = Event::builder()
.name("test_event")
.build();
}
// Observe some events first
TEST_EVENT.with(|e| e.observe_once());
let report = Report::collect();
for event in report.events() {
println!("Event: {}, Count: {}", event.name(), event.count());
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Report
impl RefUnwindSafe for Report
impl Send for Report
impl Sync for Report
impl Unpin for Report
impl UnwindSafe for Report
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more