Skip to content

Commit

Permalink
Use tags to mark individual middleware (github#17531)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonEtco authored Jan 27, 2021
1 parent 58319a2 commit 7af9e3b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/instrument-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ module.exports = function instrumentMiddleware (relativePath) {
// Check if the middleware is an async function, to use the appropriate timer
const isAsyncFunction = middleware.constructor.name === 'AsyncFunction'

// Name it `middleware.<filename>`
const name = `middleware.${path.basename(relativePath)}`
// Add a tag so we can see all middleware together
const tags = { middleware: path.basename(relativePath) }

return isAsyncFunction
? statsd.asyncTimer(middleware, name)
: statsd.timer(middleware, name)
? statsd.asyncTimer(middleware, 'middleware', tags)
: statsd.timer(middleware, 'middleware', tags)
}

0 comments on commit 7af9e3b

Please sign in to comment.