#[metrics]Expand description
A macro used to create metric handlers.
You can change the crate by specifying #[metrics(crate_path = "...")].
Module Attributes:
crate_path: Thescuffle_metricscrate path.rename: The name of the metric container.
Function Attributes:
crate_path: Thescuffle_metricscrate path.builder: The builder to use for the metric.unit: The unit of the metric.rename: The name of the metric.
Function Arguments Attributes:
rename: The name of the argument.
When using the module, you do not need to attribute each function with the
#[metrics] attribute. All non function definitions are ignored.
§Module Example
#[scuffle_metrics::metrics]
mod example {
use scuffle_metrics::{MetricEnum, collector::CounterU64};
#[derive(MetricEnum)]
pub enum Kind {
Http,
Grpc,
}
#[metrics(unit = "requests")]
pub fn request(kind: Kind) -> CounterU64;
}
// Increment the counter
example::request(example::Kind::Http).incr();§Function Example
#[scuffle_metrics::metrics(unit = "requests")]
pub fn request(kind: Kind) -> CounterU64;
// Increment the counter
request(Kind::Http).incr();