MCPcopy Index your code
hub / github.com/containerd/containerd / assertCounter

Function assertCounter

internal/nri/metrics_test.go:145–167  ·  view source on GitHub ↗
(t *testing.T, name string, labels map[string]string, wantMin float64)

Source from the content-addressed store, hash-verified

143}
144
145func assertCounter(t *testing.T, name string, labels map[string]string, wantMin float64) {
146 t.Helper()
147 families, err := prometheus.DefaultGatherer.Gather()
148 require.NoError(t, err)
149
150 var found bool
151 for _, f := range families {
152 if f.GetName() != name {
153 continue
154 }
155 for _, m := range f.Metric {
156 if matchesLabels(m.Label, labels) {
157 found = true
158 if m.GetCounter() != nil {
159 assert.GreaterOrEqual(t, m.GetCounter().GetValue(), wantMin)
160 } else {
161 t.Fatalf("metric %s is not a counter", name)
162 }
163 }
164 }
165 }
166 assert.True(t, found, "metric %s with labels %v not found", name, labels)
167}
168
169func assertGauge(t *testing.T, name string, want float64) {
170 t.Helper()

Calls 3

matchesLabelsFunction · 0.85
GetValueMethod · 0.80
GetNameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…