Skip to content

Commit 0b02704

Browse files
authored
vec: fix example in with_label_values() (#359)
Signed-off-by: David Ortiz <[email protected]>
1 parent 512e8ed commit 0b02704

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/vec.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,18 @@ impl<T: MetricVecBuilder> MetricVec<T> {
242242
}
243243

244244
/// `with_label_values` works as `get_metric_with_label_values`, but panics if an error
245-
/// occurs. The method allows neat syntax like:
246-
/// httpReqs.with_label_values("404", "POST").inc()
245+
/// occurs.
246+
///
247+
/// # Examples
248+
///
249+
/// ```
250+
/// use prometheus::{CounterVec, Opts};
251+
/// let vec = CounterVec::new(
252+
/// Opts::new("requests", "Number of requests"),
253+
/// &["code", "http_method"]
254+
/// ).unwrap();
255+
/// vec.with_label_values(&["404", "POST"]).inc()
256+
/// ```
247257
pub fn with_label_values(&self, vals: &[&str]) -> T::M {
248258
self.get_metric_with_label_values(vals).unwrap()
249259
}

0 commit comments

Comments
 (0)