#observability #metrics #monitoring

metriki-core

A metrics library ported from dropwizard metrics

20 releases (stable)

1.7.4 Mar 24, 2022
1.7.2 Jan 26, 2022
1.7.1 Nov 9, 2021
1.6.0 Jul 6, 2021
0.1.4 Mar 19, 2021

#151 in Debugging

Download history 162/week @ 2022-06-04 19/week @ 2022-06-11 54/week @ 2022-06-18 22/week @ 2022-06-25 41/week @ 2022-07-02 36/week @ 2022-07-09 69/week @ 2022-07-16 69/week @ 2022-07-23 25/week @ 2022-07-30 63/week @ 2022-08-06 50/week @ 2022-08-13 66/week @ 2022-08-20 24/week @ 2022-08-27 53/week @ 2022-09-03 68/week @ 2022-09-10 44/week @ 2022-09-17

210 downloads per month
Used in fewer than 12 crates

MIT/Apache

38KB
897 lines

Metriki

Metriki is a rust library ported from Dropwizard Metrics.

Like Dropwizard Metrics, Metriki aggregates metrics on client-side and outputs limited amount data.

Quick Start

// create a timer to track the execution rate and latency of this function
// to use macros you will need to turn on `macros` feature of metriki_core
#[timed]
fn your_function() {
  // a function metered by a timer for its rate and latency
}

use metriki_core::global::global_registry;
use metriki_influxdb_reporter::InfluxDbReporterBuilder;

// by default, the timer is registered in this global_registry()
let registry = global_registry();

// start a reporter to send data into influxdb
InfluxDbReporterBuilder::default()
  .registry(registry.clone())
  .build()
  .start();

Components

Concepts

Metrics

  • Counter: a value that can be increased and decreased.
  • Meter: measures rate of an event.
  • Histogram: records distribution of data over time.
  • Timer: a combination of meter and histogram.
  • Gauge: a function that provides value when queried.

MetricsRegistry

An entrypoint and holder of all metrics.

MetricsSet

A trait to be implemented so that dynamic metrics can be added into registry. Metrics from the set are pulled into registry everytime when reporters and exporters pulling values from the registry.

Reporter

A component to report metric data periodically. Typically used for data sinks which has a push-model.

Exporter

A component to expose metric data to external queriers. Typically for pull based data sinks.

License

MIT/Apache-2.0

Dependencies

~1.4–6.5MB
~106K SLoC