Skip to content

chore: add prometheus timing to latency endpoint #7742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prevent panic
  • Loading branch information
Emyrk committed May 31, 2023
commit b7a77c70bc9c4b10a21171b6038d25c6753452a2
5 changes: 4 additions & 1 deletion coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,10 @@ func New(options *Options) *API {
// This is the only route we add before all the middleware.
// We want to time the latency of the request, so any middleware will
// interfere with that timing.
rootRouter.Get("/latency-check", prometheusMW(cors(LatencyCheck(options.DeploymentValues.Dangerous.AllowAllCors.Value(), api.AccessURL))).ServeHTTP)
rootRouter.Route("/latency-check", func(r chi.Router) {
r.Use(tracing.StatusWriterMiddleware, prometheusMW, cors)
r.Get("/", LatencyCheck(options.DeploymentValues.Dangerous.AllowAllCors.Value(), api.AccessURL))
})
rootRouter.Mount("/", r)
api.RootHandler = rootRouter

Expand Down
5 changes: 4 additions & 1 deletion enterprise/wsproxy/wsproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ 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", prometheusMW(corsMW(coderd.LatencyCheck(opts.AllowAllCors, s.DashboardURL, s.AppServer.AccessURL))).ServeHTTP)
rootRouter.Route("/latency-check", func(r chi.Router) {
r.Use(tracing.StatusWriterMiddleware, prometheusMW, corsMW)
r.Get("/", coderd.LatencyCheck(opts.AllowAllCors, s.DashboardURL, s.AppServer.AccessURL))
})
rootRouter.Mount("/", r)
s.Handler = rootRouter

Expand Down