Crate dipstick [] [src]

A fast and modular metrics library decoupling app instrumentation from reporting backend. Similar to popular logging frameworks, but with counters and timers. Can be configured for combined outputs (log + statsd), random sampling, local aggregation of metrics, recurrent background publication, etc.

Reexports

pub use aggregate::*;
pub use publish::*;
pub use statsd::*;
pub use logging::*;
pub use cache::*;

Modules

aggregate

Maintain aggregated metrics for deferred reporting,

cache

Cache defined metrics.

error

Dipstick uses error_chain to handle the critical errors that might crop up when assembling the backend.

logging

Write metrics to log

publish

Publish metrics from a source to sink.

sampling

Reduce the amount of data to process or transfer by statistically dropping some of it.

statsd

Send metrics to a statsd server.

Macros

time

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.

Structs

Counter

A gauge that sends values to the metrics backend

DoubleKey

Hold each sink's metric key.

DoubleSink

Hold the two target sinks. Multiple DoubleSinks can be combined if more than two sinks are needed.

DoubleWriter

Write the metric values to each sink.

Event

A monotonic counter metric. Since value is only ever increased by one, no value parameter is provided, preventing potential problems.

Gauge

A counter that sends values to the metrics backend

Metrics

Application metrics are defined here.

TimeHandle

A handle to the start time of a counter. Wrapped so it may be changed safely later.

Timer

A timer that sends values to the metrics backend Timers can record time intervals in multiple ways : - with the time! macro, which wraps an expression or block with start() and stop() calls. - with the time(Fn) method, which wraps a closure with start() and stop() calls. - with start() and stop() methods, wrapping around the operation to time - with the interval_us() method, providing an externally determined microsecond interval

Enums

MetricKind

Used to differentiate between metric kinds in the backend.

Constants

FULL_SAMPLING_RATE

Do not sample, use all data.

Traits

AsSink

Metric sink trait

AsSource

Metric source trait

IntoSink

Metric sink trait

MetricKey

A metric identifier defined by a specific metric sink implementation. Passed back to when writing a metric value May carry state specific to the sink's implementation

MetricSink

Main trait of the metrics backend API. Defines a component that can be used when setting up a metrics backend stack. Intermediate sinks transform how metrics are defined and written: - Sampling - Dual - Cache Terminal sinks store or propagate metric values to other systems. - Statsd - Log - Aggregate

MetricWriter

A sink-specific target for writing metrics to.

ToPrimitive

A generic trait for converting a value to a number.

ToSocketAddrs

A trait for objects which can be converted or resolved to one or more SocketAddr values.

Functions

aggregate

Aggregate metrics in memory. Depending on the type of metric, count, sum, minimum and maximum of values will be tracked. Needs to be connected to a publish to be useful.

cache

Cache metrics to prevent them from being re-defined on every use. Use of this should be transparent, this has no effect on the values. Stateful sinks (i.e. Aggregate) may naturally cache their definitions.

log

Send metric to a logger. This uses the basic log crate as it is configured for the application.

metrics

Wrap the metrics backend to provide an application-friendly interface.

publish

Publishes all metrics from a source to a backend.

sample

Perform random sampling of values according to the specified rate.

statsd

Send metrics to a statsd server at the address and port provided.

Type Definitions

Rate

Base type for sampling rate. 1.0 takes everything. 0.5 takes one sample every two measures. 0.0 takes nothing.

Value

Base type for recorded metric values.