(t *testing.T)
| 411 | } |
| 412 | |
| 413 | func TestDERPMetrics(t *testing.T) { |
| 414 | t.Parallel() |
| 415 | |
| 416 | _, _, api := coderdtest.NewWithAPI(t, nil) |
| 417 | |
| 418 | require.NotNil(t, api.Options.DERPServer, "DERP server should be configured") |
| 419 | require.NotNil(t, api.Options.PrometheusRegistry, "Prometheus registry should be configured") |
| 420 | |
| 421 | // The registry is created internally by coderd. Gather from it |
| 422 | // to verify DERP metrics were registered during startup. |
| 423 | metrics, err := api.Options.PrometheusRegistry.Gather() |
| 424 | require.NoError(t, err) |
| 425 | |
| 426 | names := make(map[string]struct{}) |
| 427 | for _, m := range metrics { |
| 428 | names[m.GetName()] = struct{}{} |
| 429 | } |
| 430 | |
| 431 | assert.Contains(t, names, "coder_derp_server_connections", |
| 432 | "expected coder_derp_server_connections to be registered") |
| 433 | assert.Contains(t, names, "coder_derp_server_bytes_received_total", |
| 434 | "expected coder_derp_server_bytes_received_total to be registered") |
| 435 | assert.Contains(t, names, "coder_derp_server_packets_dropped_reason_total", |
| 436 | "expected coder_derp_server_packets_dropped_reason_total to be registered") |
| 437 | } |
| 438 | |
| 439 | // TestRateLimitByUser verifies that rate limiting keys by user ID when |
| 440 | // an authenticated session is present, rather than falling back to IP. |
nothing calls this directly
no test coverage detected