12 releases
new 0.2.1 | Nov 19, 2024 |
---|---|
0.1.9 | Sep 21, 2024 |
0.1.5 | Jul 19, 2024 |
0.1.0 | Mar 15, 2024 |
#25 in #telemetry
28 downloads per month
Used in 4 crates
160KB
4K
SLoC
Tracing crate
Provides logging, metrics, memory and performance profiling
Have the lowest impact on the critical path of execution while providing great
visibility, tracing
focusses on providing predictable performance for high
performance applications. It was originaly designed for video game engines.
Contrary to other tracing crates, tracing does not provide hooks for individual events but rather a stream of events, internally it leverages transit to serialize the events into a binary format. meant to be consumed later on in process but can also be sent efficiently over the wire.
Examples
use micromegas_tracing::{
span_scope, info, warn, error, debug, imetric, fmetric, guards, event,
};
// Initialize tracing, here with a null event sink, see `lgn-telemetry-sink` crate for a proper implementation
// libraries don't need (and should not) setup any TracingSystemGuard
let _tracing_guard = guards::TracingSystemGuard::new(
8 * 1024 * 1024,
1024 * 1024,
16 * 1024 * 1024,
std::sync::Arc::new(event::NullEventSink {})
);
let _thread_guard = guards::TracingThreadGuard::new();
// Create a span scope, this will complete when the scope is dropped, and provide the time spent in the scope
// Behind the scene this uses a thread local storage
// on an i9-11950H this takes around 40ns
span_scope!("main");
// Logging
info!("Hello world");
warn!("Hello world");
error!("Hello world");
debug!("Hello world");
// Metrics
imetric!("name", "unit", 0);
fmetric!("name", "unit", 0.0);
Dependencies
~2.4–3.5MB
~63K SLoC