tinymetrics
a minimal, allocation-free Prometheus/OpenMetrics metrics implementation for no-std
and embedded projects.
why should you use it?
you may want to use this crate if:
- you want the Prometheus/OpenMetrics text exposition format. other metrics systems are not supported. if you want a generic way to record metrics that can be emitted in a number of different formats, the i highly recommend the
metrics
crate and its ecosystem, which provide a generic facade implementation that can be used with multiple metrics systems. however, these libraries may be less suitable for use in embedded systems — read on for why. - you can't (or don't want to) allocate memory dynamically. this crate is intended to allow all metrics storage to be declared in
static
s, for use in embedded systems and otherno-std
use-cases. in order to support completely static usage, this crate has some additional limitations over other Prometheus/OpenMetrics implementations. in particular: - the cardinality of metrics labels is known ahead of time. because
tinymetrics
stores metrics instatic
, fixed-size arrays, the maximum size of the label set of each metric must be declared at compile time. this is an inherent limitation to using static storage, but it may be acceptable if you only want to expose a small number of metrics with known labels. - you only need counter and gauge metrics. i haven't implemented the summary and histogram metric types yet, although it would be nice to eventually.