| 144 | } |
| 145 | |
| 146 | func assertGauges(t *testing.T, reg *prometheus.Registry, want gaugeExpectations) { |
| 147 | t.Helper() |
| 148 | families, err := reg.Gather() |
| 149 | require.NoError(t, err) |
| 150 | |
| 151 | got := map[string]float64{} |
| 152 | for _, f := range families { |
| 153 | require.Len(t, f.GetMetric(), 1, "metric %q should have exactly one sample", f.GetName()) |
| 154 | got[f.GetName()] = f.GetMetric()[0].GetGauge().GetValue() |
| 155 | } |
| 156 | |
| 157 | assert.Equal(t, want.active, got["coderd_chatd_streams_active"], "streams_active") |
| 158 | assert.Equal(t, want.bufferMax, got["coderd_chatd_stream_buffer_size_max"], "buffer_size_max") |
| 159 | assert.Equal(t, want.bufferTotal, got["coderd_chatd_stream_buffer_events"], "buffer_events") |
| 160 | assert.Equal(t, want.subscribers, got["coderd_chatd_stream_subscribers"], "subscribers") |
| 161 | } |
| 162 | |
| 163 | func newSubscribers(t *testing.T, n int) map[uuid.UUID]chan codersdk.ChatStreamEvent { |
| 164 | t.Helper() |