MCPcopy Index your code
hub / github.com/coder/coder / MetricValue

Function MetricValue

coderd/coderdtest/promhelp/metrics.go:67–87  ·  view source on GitHub ↗
(t testing.TB, reg prometheus.Gatherer, metricName string, labels prometheus.Labels)

Source from the content-addressed store, hash-verified

65}
66
67func MetricValue(t testing.TB, reg prometheus.Gatherer, metricName string, labels prometheus.Labels) *io_prometheus_client.Metric {
68 t.Helper()
69
70 metrics, err := reg.Gather()
71 require.NoError(t, err)
72
73 for _, m := range metrics {
74 if m.GetName() == metricName {
75 for _, labeled := range m.GetMetric() {
76 mLabels := make(prometheus.Labels)
77 for _, v := range labeled.GetLabel() {
78 mLabels[v.GetName()] = v.GetValue()
79 }
80 if maps.Equal(mLabels, labels) {
81 return labeled
82 }
83 }
84 }
85 }
86 return nil
87}

Callers 9

TestMetricsFunction · 0.92
TestUpdateLifecycleFunction · 0.92
TestInstrumentFunction · 0.92
TestGithubRateLimitsFunction · 0.92
HistogramValueFunction · 0.85
GaugeValueFunction · 0.85
CounterValueFunction · 0.85

Calls 4

HelperMethod · 0.65
GetNameMethod · 0.45
GetValueMethod · 0.45
EqualMethod · 0.45

Tested by 6

TestMetricsFunction · 0.74
TestUpdateLifecycleFunction · 0.74
TestInstrumentFunction · 0.74
TestGithubRateLimitsFunction · 0.74