Introducing rust-prometheus
How Rust makes metrics safe and fast
- Track: Rust devroom
- Room: UD2.208 (Decroly)
- Day: Sunday
- Start: 12:30
- End: 13:15
This talk is to give a brief introduction to the rust-prometheus library, which is a Rust client for Prometheus, a monitoring and alerting toolkit. After a brief look at basic usage, this talk will dive into how Rust features make the library safe and fast. Finally, we will discuss some ways to use Procedural Macros to reduce metric lookup by over 10x via generated static lookups.
Intended audience: Rust beginner
Agenda
- Introduction (5 min)
- Self introduction
- What is Rust-Prometheus: A brief introduction to Prometheus and the client library
- How to use: A short example of using the library to collect different kind of metrics
- How Rust Shines
- Safe (5 min)
- Why we care about safety
- Type-safe generic labels: Use generic label length so that label length can be checked at compile time.
- Rust’s Send & Sync markers
- Rust’s #[must_use] attribute
- Fast (5 min)
- Why we care about performance
- Local !Sync metrics: Shared global metrics across threads is not efficient, e.g. causing cache eviction. Local metrics to solve under the cost of normal variables!
- Static metric vectors via proc_macros: A macro to provide efficient metric vectors.
- Safe (5 min)
- How static metric macro is implemented (10 min)
- A small explanation of the macro implementation so that listeners will have a blueprint about the capability and the approach of Rust procedural macros.
- Benchmarks showing speed difference.
- Future Plan (2 min)
- Thread-local metrics: Enables seamlessly local metrics and less contention
- More metrics, like Prometheus Summary
- A more consistent API
- Metrics pulling
- Contributions are welcome!
- Production Use Case (5 min)
Speakers
Wish Shi |