// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. extern crate prometheus; extern crate prometheus_static_metric; use prometheus::{CounterVec, Opts}; use prometheus_static_metric::make_static_metric; make_static_metric! { pub struct MyStaticCounterVec: Counter { "method" => { post, get, put, delete, }, "product" => { foo, bar, }, } } fn main() { let vec = CounterVec::new(Opts::new("foo", "bar"), &["method", "product"]).unwrap(); let static_counter_vec = MyStaticCounterVec::from(&vec); static_counter_vec.post.foo.inc(); static_counter_vec.delete.bar.inc_by(4.0); assert_eq!(static_counter_vec.post.bar.get(), 0.0); assert_eq!(vec.with_label_values(&["post", "foo"]).get(), 1.0); assert_eq!(vec.with_label_values(&["delete", "bar"]).get(), 4.0); }