mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Check that req.route.path is set
This commit is contained in:
parent
284d8fb588
commit
1dea55d8f2
1 changed files with 18 additions and 16 deletions
|
@ -8,22 +8,24 @@ module.exports.monitor = (logger) ->
|
||||||
res.end = () ->
|
res.end = () ->
|
||||||
end.apply(this, arguments)
|
end.apply(this, arguments)
|
||||||
responseTime = new Date() - startTime
|
responseTime = new Date() - startTime
|
||||||
routePath = req.route.path.toString().replace(/\//g, '_').replace(/\:/g, '').slice(1)
|
if req.route?.path?
|
||||||
key = "http-requests.#{routePath}.#{req.method}.#{res.statusCode}"
|
routePath = req.route.path.toString().replace(/\//g, '_').replace(/\:/g, '').slice(1)
|
||||||
|
key = "http-requests.#{routePath}.#{req.method}.#{res.statusCode}"
|
||||||
|
|
||||||
Metrics.timing(key, responseTime)
|
Metrics.timing(key, responseTime)
|
||||||
logger.log
|
logger.log
|
||||||
req:
|
req:
|
||||||
url: req.originalUrl || req.url
|
url: req.originalUrl || req.url
|
||||||
method: req.method
|
method: req.method
|
||||||
referrer: req.headers['referer'] || req.headers['referrer']
|
referrer: req.headers['referer'] || req.headers['referrer']
|
||||||
"remote-addr": req.ip || req.socket?.socket?.remoteAddress || req.socket?.remoteAddress
|
"remote-addr": req.ip || req.socket?.socket?.remoteAddress || req.socket?.remoteAddress
|
||||||
"user-agent": req.headers["user-agent"]
|
"user-agent": req.headers["user-agent"]
|
||||||
"content-length": req.headers["content-length"]
|
"content-length": req.headers["content-length"]
|
||||||
res:
|
res:
|
||||||
"content-length": res._headers?["content-length"]
|
"content-length": res._headers?["content-length"]
|
||||||
statusCode: res.statusCode
|
statusCode: res.statusCode
|
||||||
"response-time": responseTime
|
"response-time": responseTime
|
||||||
"http request"
|
"http request"
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue