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

Function getCounterVecValue

agent/boundarylogproxy/proxy_test.go:816–836  ·  view source on GitHub ↗

getCounterVecValue returns the current value of a CounterVec metric filtered by the given reason label.

(t *testing.T, reg *prometheus.Registry, name, reason string)

Source from the content-addressed store, hash-verified

814// getCounterVecValue returns the current value of a CounterVec metric filtered
815// by the given reason label.
816func getCounterVecValue(t *testing.T, reg *prometheus.Registry, name, reason string) float64 {
817 t.Helper()
818
819 metrics, err := reg.Gather()
820 require.NoError(t, err)
821
822 for _, mf := range metrics {
823 if mf.GetName() != name {
824 continue
825 }
826 for _, m := range mf.GetMetric() {
827 for _, lp := range m.GetLabel() {
828 if lp.GetName() == "reason" && lp.GetValue() == reason {
829 return m.GetCounter().GetValue()
830 }
831 }
832 }
833 }
834
835 return 0
836}
837
838// getCounterValue returns the current value of a Counter metric.
839func getCounterValue(t *testing.T, reg *prometheus.Registry, name string) float64 {

Callers 1

TestServer_MetricsFunction · 0.85

Calls 3

HelperMethod · 0.65
GetNameMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected