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

Function TestDERPMetrics

coderd/coderd_test.go:413–437  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

411}
412
413func 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.

Callers

nothing calls this directly

Calls 3

NewWithAPIFunction · 0.92
GetNameMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected