1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
//! # metriki-core //! //! Metriki-core is a metrics library that ported from Coda Hale's Dropwizard Metrics. //! //! This library heavily relies on exponential moving average and exponential decay algorithms //! for its meter and histogram implementation. So it won't stop all the samples in memory and //! works great on application with heavy load. //! //! Currently the library supports five kinds of metrics, includes: //! //! * Meter: a measure for rate, useful for tracking QPS, error rate, etc. //! * Histogram: distribution of a series of numerical data //! * Timer: a combination of meter and histogram, for tracking latency and rate at the same time //! * Counter: just counter //! * Gauge: a function that reports a value when it is called //! //! ## Ecosystem //! //! ### Reporters //! //! Like Dropwizard Metrics, reporters are component that fetches data from registry and sents //! to some destination. //! //! A [Log reporter](https://github.com/sunng87/metriki/tree/master/metriki-log-reporter) is //! the reference implementation. //! //! ### Integrations //! //! We will try to integrate metriki with some common libraries/frameworks of Rust ecosystem, //! includes web frameworks, net programming frameworks, database connectors, etc. //! //! ## Usage //! //! Create a `MetricsRegistry` for your application as the entrypoint and holder of all metrics. //! //! ``` //! use metriki_core::MetricsRegistry; //! //! let registry = MetricsRegistry::new(); //! //! // using meter: mark an event as it happened once //! registry.meter("event").mark(); //! //! // record a sample value 42 into my_data series //! registry.histogram("my_data").update(42); //! //! // increase my_counter by 1 //! registry.counter("my_counter").inc(1); //! //! // start a timer and record its rate //! let my_timer = registry.timer("my_timer"); //! let timer_context = my_timer.start(); //! // stop the timer and record its data //! timer_context.stop(); //! //! // register a gauge function //! registry.gauge("my_gauge", Box::new(|| { //! 42.0 //! })) //! ``` //! pub mod metrics; mod registry; mod utils; pub use registry::MetricsRegistry;