Skip to content

Commit

Permalink
add metrics routes
Browse files Browse the repository at this point in the history
  • Loading branch information
denopink committed Nov 7, 2022
1 parent b988bda commit f5c9333
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ type metricMiddlewareOut struct {
Health alice.Chain `name:"middleware_health_metrics"`
}

type metricsRoutesIn struct {
fx.In
Router *mux.Router `name:"server_metrics"`
Handler touchhttp.Handler
}

func provideServers() fx.Option {
return fx.Options(
arrange.ProvideKey(reqMaxRetriesKey, 0),
Expand Down Expand Up @@ -176,6 +182,7 @@ func provideServers() fx.Option {
fx.Invoke(
handlePrimaryEndpoint,
handleWebhookRoutes,
buildMetricsRoutes,
),
)
}
Expand Down Expand Up @@ -385,3 +392,9 @@ func v2ErrEncode(w http.ResponseWriter, logger log.Logger, err error, code int)
"message": err.Error(),
})
}

func buildMetricsRoutes(in metricsRoutesIn) {
if in.Router != nil && in.Handler != nil {
in.Router.Handle("/metrics", in.Handler).Methods("GET")
}
}

0 comments on commit f5c9333

Please sign in to comment.