getCounterValue returns the current value of a Counter metric.
(t *testing.T, reg *prometheus.Registry, name string)
| 837 | |
| 838 | // getCounterValue returns the current value of a Counter metric. |
| 839 | func 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 | } |
no test coverage detected