Skip to content

Commit

Permalink
Merge pull request #45 from topfreegames/fix/middleware-response-ms
Browse files Browse the repository at this point in the history
Send response time metric in milliseconds on middleware
  • Loading branch information
miguelreiswildlife authored Oct 31, 2024
2 parents ce5e3fe + 7705ab0 commit a20d499
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions echo/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type ResponseTimeMetricsMiddleware struct {
AddCustomTags func(echo.Context) []string
}

//ResponseTimeMetricsMiddleware is a middleware to measure the response time
//of a route and send it do StatsD
// ResponseTimeMetricsMiddleware is a middleware to measure the response time
// of a route and send it do StatsD
func (responseTimeMiddleware ResponseTimeMetricsMiddleware) Serve(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
startTime := time.Now()
Expand All @@ -41,13 +41,13 @@ func (responseTimeMiddleware ResponseTimeMetricsMiddleware) Serve(next echo.Hand
tags = append(tags, customizedTags...)
}

responseTimeMiddleware.DDStatsD.Distribution(metricName, float64(timeUsed), tags...)
responseTimeMiddleware.DDStatsD.Distribution(metricName, float64(timeUsed.Milliseconds()), tags...)

return result
}
}

//ResponseTimeMetricsMiddleware returns a new ResponseTimeMetricsMiddleware
// ResponseTimeMetricsMiddleware returns a new ResponseTimeMetricsMiddleware
func NewResponseTimeMetricsMiddleware(ddStatsD *middleware.DogStatsD) *ResponseTimeMetricsMiddleware {
return &ResponseTimeMetricsMiddleware{
DDStatsD: ddStatsD,
Expand Down

0 comments on commit a20d499

Please sign in to comment.