getCounterVecValue returns the current value of a CounterVec metric filtered by the given reason label.
(t *testing.T, reg *prometheus.Registry, name, reason string)
| 814 | // getCounterVecValue returns the current value of a CounterVec metric filtered |
| 815 | // by the given reason label. |
| 816 | func 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. |
| 839 | func getCounterValue(t *testing.T, reg *prometheus.Registry, name string) float64 { |
no test coverage detected