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

Method With

prometheus/gauge.go:247–253  ·  view source on GitHub ↗

With works as GetMetricWith, but panics where GetMetricWithLabels would have returned an error. Not returning an error allows shortcuts like myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42)

(labels Labels)

Source from the content-addressed store, hash-verified

245//
246// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42)
247func (v *GaugeVec) With(labels Labels) Gauge {
248 g, err := v.GetMetricWith(labels)
249 if err != nil {
250 panic(err)
251 }
252 return g
253}
254
255// CurryWith returns a vector curried with the provided labels, i.e. the
256// returned vector has those labels pre-set for all labeled operations performed

Callers 3

ExampleGaugeVecFunction · 0.95
TestWriteToTextfileFunction · 0.95
benchmarkMetricVecWithFunction · 0.95

Calls 1

GetMetricWithMethod · 0.95

Tested by 3

ExampleGaugeVecFunction · 0.76
TestWriteToTextfileFunction · 0.76
benchmarkMetricVecWithFunction · 0.76