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

Function ExampleGaugeVec

prometheus/examples_test.go:52–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50}
51
52func ExampleGaugeVec() {
53 opsQueued := prometheus.NewGaugeVec(
54 prometheus.GaugeOpts{
55 Namespace: "our_company",
56 Subsystem: "blob_storage",
57 Name: "ops_queued",
58 Help: "Number of blob storage operations waiting to be processed, partitioned by user and type.",
59 },
60 []string{
61 // Which user has requested the operation?
62 "user",
63 // Of what type is the operation?
64 "type",
65 },
66 )
67 prometheus.MustRegister(opsQueued)
68
69 // Increase a value using compact (but order-sensitive!) WithLabelValues().
70 opsQueued.WithLabelValues("bob", "put").Add(4)
71 // Increase a value with a map using WithLabels. More verbose, but order
72 // doesn't matter anymore.
73 opsQueued.With(prometheus.Labels{"type": "delete", "user": "alice"}).Inc()
74}
75
76func ExampleGaugeFunc_simple() {
77 if err := prometheus.Register(prometheus.NewGaugeFunc(

Callers

nothing calls this directly

Calls 6

WithLabelValuesMethod · 0.95
WithMethod · 0.95
NewGaugeVecFunction · 0.92
MustRegisterFunction · 0.92
AddMethod · 0.65
IncMethod · 0.65

Tested by

no test coverage detected