INSTALLATION
[]
= "0.2.1"
Or with optional actix-web HTTP endpoint
[]
= { = "0.2.1", = ["http"] }
HOW TO USE
ONE: Define
#[derive(serde::Serialize)] is only needed for the http feature
#[derive(Debug, Clone, PartialEq, Eq, Hash)] is mandatory
- Choose
anyname for theenumtype - Each
variantcorresponds to a key and may benamed however you like - There’s
no limiton how manykeys (variants)you define
TWO: Initialize
async
Or with the actix-web HTTP feature
async
pub fn init<K>(address: &str, port: &str, path: &str, workers: &str)
http://127.0.0.1:8080/metrics
- address: The IP address on which the HTTP server will listen
- port: The port number to listen on
- path: The URL segment
(without leading slash)that is exposed - workers: How many actix-web
worker threadsto spawn- A value of
"all"or""will spawn the default amount(matches the number of CPU cores) - Or give it a specific
number, such as"2"
- A value of
THREE: INCREMENT
Call the increment(Keys::Variant) function to increase that key’s counter by one
use crate*;
use increment;
async
async
FOUR: Retrieve
Or with the actix-web HTTP feature
curl http://127.0.0.1:8080/metrics
// Make a custom implementation to retrieve and store your data
What you are retrieving:
MetricsSnapshot
Or the JSON version when using the HTTP feature
This translates to
INFORMATION
- Both the per second and per minute calculations are computed every second
- "Real time" metrics are possible