MCPcopy
hub / github.com/prometheus/client_golang / WithLabelValues

Method WithLabelValues

prometheus/counter.go:281–287  ·  view source on GitHub ↗

WithLabelValues works as GetMetricWithLabelValues, but panics where GetMetricWithLabelValues would have returned an error. Not returning an error allows shortcuts like myVec.WithLabelValues("404", "GET").Add(42)

(lvs ...string)

Source from the content-addressed store, hash-verified

279//
280// myVec.WithLabelValues("404", "GET").Add(42)
281func (v *CounterVec) WithLabelValues(lvs ...string) Counter {
282 c, err := v.GetMetricWithLabelValues(lvs...)
283 if err != nil {
284 panic(err)
285 }
286 return c
287}
288
289// With works as GetMetricWith, but panics where GetMetricWithLabels would have
290// returned an error. Not returning an error allows shortcuts like

Callers 15

ExampleCounterVecFunction · 0.95
ExampleRegisterFunction · 0.95
testHandlerFunction · 0.95
BenchmarkCounterFunction · 0.95
InstrumentMetricHandlerFunction · 0.95
TestHandlerErrorHandlingFunction · 0.95
TestToFloat64Function · 0.95
TestCollectAndCountFunction · 0.95

Calls 1

Tested by 15

ExampleCounterVecFunction · 0.76
ExampleRegisterFunction · 0.76
testHandlerFunction · 0.76
BenchmarkCounterFunction · 0.76
TestHandlerErrorHandlingFunction · 0.76
TestToFloat64Function · 0.76
TestCollectAndCountFunction · 0.76
TestCollectAndFormatFunction · 0.76