diff --git a/echo/middleware/middleware.go b/echo/middleware/middleware.go index aa041f4..c9c28ab 100644 --- a/echo/middleware/middleware.go +++ b/echo/middleware/middleware.go @@ -12,7 +12,8 @@ const metricName = "response_time_milliseconds" // ResponseTimeMetricsMiddleware struct encapsulating DDStatsD type ResponseTimeMetricsMiddleware struct { - DDStatsD *middleware.DogStatsD + DDStatsD *middleware.DogStatsD + AddCustomTags func(echo.Context) []string } //ResponseTimeMetricsMiddleware is a middleware to measure the response time @@ -35,6 +36,10 @@ func (responseTimeMiddleware ResponseTimeMetricsMiddleware) Serve(next echo.Hand if gameID != "" { tags = append(tags, fmt.Sprintf("game:%s", gameID)) } + if responseTimeMiddleware.AddCustomTags != nil { + customizedTags := responseTimeMiddleware.AddCustomTags(c) + tags = append(tags, customizedTags...) + } responseTimeMiddleware.DDStatsD.Timing(metricName, timeUsed, tags...)