#[derive(EncodeLabelSet)]
{
// Attributes available to this derive:
#[label]
}
Expand description
Derives EncodeLabelSet for a struct.
Each field becomes a label with the field name as the key.
Use #[label(name = "custom")] to customize the label key.
Use #[label(skip)] to exclude a field from the label set.
Use #[label(rename_all = "...")] on the struct to rename all fields by
case rule. Supported rules: snake_case, camelCase, PascalCase,
SCREAMING_SNAKE_CASE, kebab-case, lowercase, UPPERCASE.
Field types must implement EncodeLabelValue. Out of the box this
covers String, &'static str, the integer types, and bool.
The struct must also derive Clone, Hash, PartialEq, and Eq.
To use the label set with Family, also derive PartialOrd and Ord
(the encoder produces output sorted by label set).
ยงExample
use iroh_metrics::EncodeLabelSet;
#[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet)]
#[label(rename_all = "kebab-case")]
struct HttpLabels {
method: String,
#[label(name = "status_code")]
status: u16,
}