pub trait SetMetric {
// Required method
fn name(&self) -> &'static str;
}
Expand description
A metric for capturing sets.
Sets count the number of unique elements in a group. You can use them to, for example, count the unique visitors to your site.
§Example
use relay_statsd::{metric, SetMetric};
enum MySet {
UniqueProjects,
UniqueUsers,
}
impl SetMetric for MySet {
fn name(&self) -> &'static str {
match self {
MySet::UniqueProjects => "unique_projects",
MySet::UniqueUsers => "unique_users",
}
}
}
let users = HashSet::new();
// use a set metric
metric!(set(MySet::UniqueUsers) = users.len() as i64);
// use a set metric with tags
metric!(
set(MySet::UniqueUsers) = users.len() as i64,
server = "server1",
host = "host1",
);