Skip to content

Commit 64db8c6

Browse files
committed
feat: expose DERP server debug metrics
1 parent 53c5543 commit 64db8c6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

coderd/coderd.go

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/tls"
66
"crypto/x509"
77
"database/sql"
8+
"expvar"
89
"flag"
910
"fmt"
1011
"io"
@@ -561,6 +562,10 @@ func New(options *Options) *API {
561562

562563
derpHandler := derphttp.Handler(api.DERPServer)
563564
derpHandler, api.derpCloseFunc = tailnet.WithWebsocketSupport(api.DERPServer, derpHandler)
565+
// Register DERP on expvar HTTP handler, which we serve below in the router, c.f. expvar.Handler()
566+
// These are the metrics the DERP server exposes.
567+
// TODO:
568+
expvar.Publish("derp", api.DERPServer.ExpVar())
564569
cors := httpmw.Cors(options.DeploymentValues.Dangerous.AllowAllCors.Value())
565570
prometheusMW := httpmw.Prometheus(options.PrometheusRegistry)
566571

@@ -1038,6 +1043,10 @@ func New(options *Options) *API {
10381043
r.Use(httpmw.ExtractUserParam(options.Database))
10391044
r.Get("/debug-link", api.userDebugOIDC)
10401045
})
1046+
r.Route("/derp", func(r chi.Router) {
1047+
r.Get("/traffic", options.DERPServer.ServeDebugTraffic)
1048+
})
1049+
r.Mount("/expvar", expvar.Handler()) // contains DERP metrics as well as cmdline and memstats
10411050
})
10421051
})
10431052

0 commit comments

Comments
 (0)