mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-03 14:33:15 -04:00
Fix logs not showing in google cloud console
This commit is contained in:
@@ -123,6 +123,8 @@ const requestMonitoring: RequestHandler = (req, _res, next) => {
|
||||
log(`${req.method} ${req.url}`)
|
||||
metrics.inc('http/request_count', {endpoint: req.path})
|
||||
next()
|
||||
// There's a bug worth flagging in that middleware. The timing/cleanup code after next() won't work as you expect:
|
||||
// next() is synchronous — it just hands off to the next middleware. The response hasn't been sent by the time endTs is captured. To measure actual latency you'd want to hook into res.on('finish', ...)
|
||||
const endTs = hrtime.bigint()
|
||||
const latencyMs = Number(endTs - startTs) / 1e6
|
||||
metrics.push('http/request_latency', latencyMs, {endpoint: req.path})
|
||||
|
||||
Reference in New Issue
Block a user