r/rust • • 19h ago

🎙️ discussion How do you monitor Rust web applications in production?

Disclosure: I maintain StatLite, an open-source monitoring tool that I use for my own applications running on small VPS.

I've been asked about Rust support, so I started exploring the monitoring options for Axum and Actix Web.

I've added lightweight instrumentation recipes for both frameworks. They collect request counts, HTTP errors, average response time, process CPU, and RSS - without requiring an additional monitoring crate.

In my experiments, these recipes had a smaller binary size, lower memory overhead, and a significantly smaller metrics payload than the Prometheus-based instrumentation I tested.

The recipes and benchmark results are here:

I'm also considering native integration with existing Prometheus exporters, so users don't need to add custom instrumentation.

I wonder what people here actually use to monitor their Rust applications. Prometheus, OpenTelemetry, something simpler? Are there particular libraries you'd recommend supporting?

I'd be happy to add native integrations if there is interest.

9 Upvotes

10 comments sorted by

4

u/joshuaclayton 14h ago

OpenTelemetry into Honeycomb for web applications; everything runs on Axum and otel with tracing gives plenty.

HC has a free tier as long as you stay within a certain number of events per day, which for low-traffic apps works totally fine!

1

u/fykup 14h ago

Thanks for sharing! The free tier seems reasonable for low-traffic applications. I personally prefer keeping monitoring costs independent of traffic volume and, more importantly, keeping my operational data from leaving my box.

5

u/Delicious_Pizza_653 19h ago

I keep things pretty simple, just a few custom endpoints that expose the metrics I actually need. Had a similar experience where bringing in a big observability library added more overhead than I was comfortable with for the tiny servers I run.

Most of the time I'm just watching request counts, error rates, and memory usage, and my own thin wrapper catches all of that without pulling in a dependency tree the size of a phone book. For alerts I've got a cron job that hits the health check every couple minutes and yells at me if response time crosses a threshold.

That lightweight approach you're describing matches what I landed on after a few false starts. I'd be curious if you've got any plans to support pushing metrics directly to a centralized collector without needing a separate exporter daemon, that's the one gap I haven't filled cleanly yet.

1

u/aguilasolige 15h ago

Hey do you have some code I could look at? I'd like to see your wrapper and set up for the metrics. I'm trying to do something similar 

0

u/fykup 18h ago

The "heaviness" or the current metrics ecosystem is why I built StatLite . I designed it around the Prometheus-style pull model, but direct push to a central collector is an option I might reconsider.

One idea I've had is a small local daemon that collects and aggregates metrics and forwards them to a central StatLite instance, with StatsD as another possible path. It's just an idea at this point, because I don't need that scale for my own deployments..

2

u/theelderbeever 14h ago

metrics-rs with the Prometheus exporter getting scraped by what I have available. At home standard Prometheus. At work a Vector agent. Then if I'm feeling particularly motivated I'll add OTEL but I don't often do because I often don't need it and I don't like logging into elastic which stores our traces.

1

u/fykup 14h ago

Thanks! That's exactly the kind of setup I'm interested in supporting natively. Which web framework are you using? Do you define your own HTTP metrics with metrics-rs, or use an existing middleware library for instrumentation?

1

u/theelderbeever 2h ago edited 1h ago

axum and define my own. The repeated http metrics are so few it isn't a big deal. More business specific stuff are the important ones. Which means that my biggest need is how easy it is to instrument things with custom metrics which the macros do great at

2

u/Luxalpa 9h ago

I'm using OpenTelemetry and Prometheus. Both for my own Actix Web applications and for our Axum servers at work.