Minimal, allocation-free OpenMetrics implementation for no-std/embedded Rust
github.com
github.com
if you’re wondering why it’s weird, half-finished, or under-documented, it’s because i wrote it in a couple hours to scratch my own itch, and really didn’t expect to be at the top of hackernews today! if this is something that other people are actually interested in using, i’d be happy to clean it up a bit and add some of the missing stuff…
I am currently looking into getting container-level metrics into Fargate containers.
I think the best way forward, if you want to keep working on it would be to provide good documentation on how to use it. As it reads from the README now, you need to set the amount of labels you will have before compiling? I am not a Rust user so basically have no idea how to test that thing.
For a feature request, I think histograms would be best.
Thanks again and good luck!
I’m working on autometrics (https://github.com/autometrics-dev/autometrics-rs) and people asked whether it could be used in embedded contexts but I wasn’t sure how you’d hook up the device to something like Prometheus.
Most would probably end up as pushing metrics via... something (MQTT?) to gateway that will push it to their metrics system.
Pulling/polling metrics honestly is pretty bad idea most of the time. It makes it easy to implement ("just* provide a web page with metrics) and allows poller to control intervals (which is only a problem if your configuration management isn't up to snuff), but complicates a lot, now you need to setup whole endpoint discovery instead of just saying "hey, apps, here is URL to push your metrics to, have fun".
We for long (10+ year) have system based on collectd and it's line protocol, and while it have some drawbacks (no tags, just rigid structure with host->plugin->plugin_instance->type_type instance, works well most of the time but 100% of the time), push nature is very light on resources (it's just an UDP packet full of metrics, no need to setup whole TCP connection, doesn't even need bidirectional firewall)
In my experience the discovery and configuration is needed anyway to do something with the metrics.
ARM chips intended for embedded uses also have a single wire output peripheral for tracing and similar purposes that could be used for this.
Basically they didn't allow sufficient control for low-latency applications so we just rolled our own approach that writes samples to InfluxDB.
for embedded devices (like this lib targets), having the now-removed protobuf exposition format seems like such an easy win. less memory & less work & less bandwidth.
https://github.com/prometheus/docs/blob/main/content/docs/in...
With the text based protocol this was never an issue, as the process that does the scraping can ingest metrics line by line.
This also presumably runs on an auxiliary thread, and uses a network interface not tied to production services.
Basically, the library just transforms over a statically assigned buffer.
In a lot of languages, this means you lose out on some language features, but I believe features like pattern matching are alloc free in rust.
Language features like pattern matching are not affected.This is about standard library features. You don’t get Vec or String without the alloc crate.
If you use a global allocator, when this happens is entirely non-deterministic. If you use a local iterator, at least you control when that happens, and have guarantees on the asymptotical behaviour.