1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
//! Publicly exposed metric macros are defined here. //! Although `dipstick` does not have a macro-based API, //! in some situations they can make instrumented code simpler. // TODO add #[timer("name")] method annotation processors /// A convenience macro to wrap a block or an expression with a start / stop timer. /// Elapsed time is sent to the supplied statsd client after the computation has been performed. /// Expression result (if any) is transparently returned. #[macro_export] macro_rules! time { ($timer: expr, $body: expr) => {{ let start_time = $timer.start(); let value = $body; $timer.stop(start_time); value }} }