prometheus: split off request timing information into separate mw
Tracks the worker api in addition to the composer api.
This commit is contained in:
parent
9594156baf
commit
2837b2a3ad
4 changed files with 31 additions and 9 deletions
|
|
@ -17,15 +17,23 @@ func MetricsMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
|||
if strings.HasSuffix(ctx.Path(), "/compose") {
|
||||
ComposeRequests.Inc()
|
||||
}
|
||||
|
||||
// leave tenant empty in case it's not in the context
|
||||
tenant, _ := ctx.Get(auth.TenantCtxKey).(string)
|
||||
timer := prometheus.NewTimer(httpDuration.WithLabelValues(ctx.Path(), tenant))
|
||||
defer timer.ObserveDuration()
|
||||
return next(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
func HTTPDurationMiddleware(subsystem string) func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
histogram := HTTPDurationHisto(subsystem)
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(ctx echo.Context) error {
|
||||
// leave tenant empty in case it's not in the context
|
||||
tenant, _ := ctx.Get(auth.TenantCtxKey).(string)
|
||||
timer := prometheus.NewTimer(histogram.WithLabelValues(ctx.Path(), tenant))
|
||||
defer timer.ObserveDuration()
|
||||
return next(ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func StatusMiddleware(subsystem string) func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
counter := StatusRequestsCounter(subsystem)
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue