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

Function TestLabelCheck

prometheus/promhttp/instrument_server_test.go:27–240  ·  prometheus/promhttp/instrument_server_test.go::TestLabelCheck
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestLabelCheck(t *testing.T) {
28 scenarios := map[string]struct {
29 metricName string // Defaults to "c".
30 varLabels []string
31 constLabels []string
32 curriedLabels []string
33 dynamicLabels []string
34 ok bool
35 }{
36 "empty": {
37 varLabels: []string{},
38 constLabels: []string{},
39 curriedLabels: []string{},
40 ok: true,
41 },
42 "code as single var label": {
43 varLabels: []string{"code"},
44 constLabels: []string{},
45 curriedLabels: []string{},
46 ok: true,
47 },
48 "method as single var label": {
49 varLabels: []string{"method"},
50 constLabels: []string{},
51 curriedLabels: []string{},
52 ok: true,
53 },
54 "code and method as var labels": {
55 varLabels: []string{"method", "code"},
56 constLabels: []string{},
57 curriedLabels: []string{},
58 ok: true,
59 },
60 "valid case with all labels used": {
61 varLabels: []string{"code", "method"},
62 constLabels: []string{"foo", "bar"},
63 curriedLabels: []string{"dings", "bums"},
64 dynamicLabels: []string{"dyn", "amics"},
65 ok: true,
66 },
67 "all labels used with an invalid const label name": {
68 varLabels: []string{"code", "method"},
69 constLabels: []string{"in\x80valid", "bar"},
70 curriedLabels: []string{"dings", "bums"},
71 dynamicLabels: []string{"dyn", "amics"},
72 ok: false,
73 },
74 "unsupported var label": {
75 varLabels: []string{"foo"},
76 constLabels: []string{},
77 curriedLabels: []string{},
78 ok: false,
79 },
80 "mixed var labels": {
81 varLabels: []string{"method", "foo", "code"},
82 constLabels: []string{},
83 curriedLabels: []string{},
84 ok: false,

Callers

nothing calls this directly

Calls 12

MustCurryWithMethod · 0.95
UnconstrainedLabelsTypeAlias · 0.92
ObserverVecInterface · 0.92
WithLabelFromCtxFunction · 0.85
InstrumentHandlerCounterFunction · 0.85
checkLabelsFunction · 0.85
RunMethod · 0.80
MustCurryWithMethod · 0.65
NewCounterVecMethod · 0.45
NewHistogramVecMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected