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

Function getCounterValue

agent/boundarylogproxy/proxy_test.go:839–855  ·  view source on GitHub ↗

getCounterValue returns the current value of a Counter metric.

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

Source from the content-addressed store, hash-verified

837
838// getCounterValue returns the current value of a Counter metric.
839func getCounterValue(t *testing.T, reg *prometheus.Registry, name string) float64 {
840 t.Helper()
841
842 metrics, err := reg.Gather()
843 require.NoError(t, err)
844
845 for _, mf := range metrics {
846 if mf.GetName() != name {
847 continue
848 }
849 for _, m := range mf.GetMetric() {
850 return m.GetCounter().GetValue()
851 }
852 }
853
854 return 0
855}

Callers 1

TestServer_MetricsFunction · 0.85

Calls 3

HelperMethod · 0.65
GetNameMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected