2.0.3 • Published 2 years ago
@routes/time v2.0.3
@routes/time
⏱ middleware to report route time
Accepts a callback function which will be called after the response has ended with the following named arguments:
name | type | role |
---|---|---|
method | String | HTTP Request method |
route | String | Express route (including base for routers) |
status | Number | Status Code |
duration | Number | The duration of handling the request in milliseconds (in floating point nanoseconds accuracy) |
If a no route pattern matches the request - the route will equal *
const time = require('@routes/time');
// Pass in the callback function
const measure = time(
({
method,
route,
status,
duration,
}) => statsdClient.time('my_service.time', duration, {
method,
route: route.replace(/\W/g, '_'),
status,
})
);
app.use(measure);
Example output:
my_service.time:76.641332|ms#method:post,route:_api_v1_users__user_id,status:200
2.1.0-rc-405b250
2 years ago
2.1.0-rc-7f19c01
2 years ago
2.0.3
3 years ago
2.0.2
4 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.0.0
5 years ago