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.
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