Skip to content

Commit cf19545

Browse files
changed the position of middleware
Signed-off-by: Rakib Hossain <rakib.hossain.ctr@sumologic.com>
1 parent c0a6f6b commit cf19545

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

backend/apid/apid.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ func NewRouter() *mux.Router {
201201
// Register a default handler when no routes match
202202
router.NotFoundHandler = middlewares.SimpleLogger{}.Then(http.HandlerFunc(notFoundHandler))
203203

204+
// Prometheus metrics collection middleware (APIMetrics) to track
205+
// request count, request duration, and client error count for all API endpoints.
206+
router.Use(middlewares.APIMetrics{
207+
RequestCount: RequestCount,
208+
RequestDuration: RequestDuration,
209+
ClientErrorCount: ClientErrorCount,
210+
}.Then)
211+
204212
return router
205213
}
206214

@@ -226,11 +234,6 @@ func AuthenticationSubrouter(router *mux.Router, cfg Config) *mux.Router {
226234
func CoreSubrouter(router *mux.Router, cfg Config) *mux.Router {
227235
subrouter := NewSubrouter(
228236
router.PathPrefix("/api/{group:core}/{version:v2}/"),
229-
middlewares.APIMetrics{
230-
RequestCount: RequestCount,
231-
RequestDuration: RequestDuration,
232-
ClientErrorCount: ClientErrorCount,
233-
},
234237
middlewares.Namespace{},
235238
middlewares.Authentication{Store: cfg.Store},
236239
middlewares.SimpleLogger{},

0 commit comments

Comments
 (0)