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

Function TestWrapRegisterer

prometheus/wrap_test.go:46–312  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

44}
45
46func TestWrapRegisterer(t *testing.T) {
47 now := time.Now()
48 nowFn := func() time.Time { return now }
49 simpleCnt := NewCounter(CounterOpts{
50 Name: "simpleCnt",
51 Help: "helpSimpleCnt",
52 now: nowFn,
53 })
54 simpleCnt.Inc()
55
56 simpleGge := NewGauge(GaugeOpts{
57 Name: "simpleGge",
58 Help: "helpSimpleGge",
59 })
60 simpleGge.Set(3.14)
61
62 preCnt := NewCounter(CounterOpts{
63 Name: "pre_simpleCnt",
64 Help: "helpSimpleCnt",
65 now: nowFn,
66 })
67 preCnt.Inc()
68
69 barLabeledCnt := NewCounter(CounterOpts{
70 Name: "simpleCnt",
71 Help: "helpSimpleCnt",
72 ConstLabels: Labels{"foo": "bar"},
73 now: nowFn,
74 })
75 barLabeledCnt.Inc()
76
77 bazLabeledCnt := NewCounter(CounterOpts{
78 Name: "simpleCnt",
79 Help: "helpSimpleCnt",
80 ConstLabels: Labels{"foo": "baz"},
81 now: nowFn,
82 })
83 bazLabeledCnt.Inc()
84
85 labeledPreCnt := NewCounter(CounterOpts{
86 Name: "pre_simpleCnt",
87 Help: "helpSimpleCnt",
88 ConstLabels: Labels{"foo": "bar"},
89 now: nowFn,
90 })
91 labeledPreCnt.Inc()
92
93 twiceLabeledPreCnt := NewCounter(CounterOpts{
94 Name: "pre_simpleCnt",
95 Help: "helpSimpleCnt",
96 ConstLabels: Labels{"foo": "bar", "dings": "bums"},
97 now: nowFn,
98 })
99 twiceLabeledPreCnt.Inc()
100
101 barLabeledUncheckedCollector := uncheckedCollector{barLabeledCnt}
102
103 scenarios := map[string]struct {

Callers

nothing calls this directly

Calls 12

IncMethod · 0.95
SetMethod · 0.95
NewPedanticRegistryFunction · 0.85
WrapRegistererWithPrefixFunction · 0.85
WrapRegistererWithFunction · 0.85
toMetricFamiliesFunction · 0.85
assertEqualMFsFunction · 0.85
RunMethod · 0.80
NewCounterFunction · 0.70
NewGaugeFunction · 0.70
RegisterMethod · 0.65
GatherMethod · 0.65

Tested by

no test coverage detected