tikv / rust-prometheus

Prometheus instrumentation library for Rust applications
Apache License 2.0
1.07k stars 182 forks source link

Question: can arguments for .with_label_values() be returned from the function? #474

Open Antiarchitect opened 1 year ago

Antiarchitect commented 1 year ago

Assume I have:

struct A {
    a: String,
    b: String
}

Can I effectively construct a method:

impl A {
    pub fn prometheus_label_values(&self) -> &[&str] {
        &[
            self.a.as_str(),
            self.b.as_str()
        ]
    }
}

To return arguments for with_label_values? It seems &[&str] argument type is too restrictive. Even declaring the lifetimes does not help.