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

Method WithLabelValues

prometheus/gauge.go:235–241  ·  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

233//
234// myVec.WithLabelValues("404", "GET").Add(42)
235func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge {
236 g, err := v.GetMetricWithLabelValues(lvs...)
237 if err != nil {
238 panic(err)
239 }
240 return g
241}
242
243// With works as GetMetricWith, but panics where GetMetricWithLabels would have
244// returned an error. Not returning an error allows shortcuts like

Callers 5

ExampleGaugeVecFunction · 0.95
ExampleGatherersFunction · 0.95
TestGaugeVecConcurrencyFunction · 0.95

Calls 1

Tested by 5

ExampleGaugeVecFunction · 0.76
ExampleGatherersFunction · 0.76
TestGaugeVecConcurrencyFunction · 0.76