chore: add prometheus timing to latency endpoint (#7742)

* chore: Prometheus timing to latency endpoint
This commit is contained in:
Steven Masley
2023-06-06 10:26:13 -05:00
committed by GitHub
parent 944c42dcb6
commit 72f59950f2
4 changed files with 14 additions and 22 deletions
+3 -2
View File
@@ -193,6 +193,7 @@ func New(ctx context.Context, opts *Options) (*Server, error) {
// The primary coderd dashboard needs to make some GET requests to
// the workspace proxies to check latency.
corsMW := httpmw.Cors(opts.AllowAllCors, opts.DashboardURL.String())
prometheusMW := httpmw.Prometheus(s.PrometheusRegistry)
// Routes
apiRateLimiter := httpmw.RateLimit(opts.APIRateLimit, time.Minute)
@@ -205,7 +206,7 @@ func New(ctx context.Context, opts *Options) (*Server, error) {
httpmw.AttachRequestID,
httpmw.ExtractRealIP(s.Options.RealIPConfig),
httpmw.Logger(s.Logger),
httpmw.Prometheus(s.PrometheusRegistry),
prometheusMW,
corsMW,
// HandleSubdomain is a middleware that handles all requests to the
@@ -258,7 +259,7 @@ func New(ctx context.Context, opts *Options) (*Server, error) {
// See coderd/coderd.go for why we need this.
rootRouter := chi.NewRouter()
// Make sure to add the cors middleware to the latency check route.
rootRouter.Get("/latency-check", corsMW(coderd.LatencyCheck(opts.AllowAllCors, s.DashboardURL, s.AppServer.AccessURL)).ServeHTTP)
rootRouter.Get("/latency-check", tracing.StatusWriterMiddleware(prometheusMW(coderd.LatencyCheck())).ServeHTTP)
rootRouter.Mount("/", r)
s.Handler = rootRouter