()
| 161 | }); |
| 162 | |
| 163 | const monitorEndOfRequest = () => { |
| 164 | if (req.serverAccessLog) { |
| 165 | // eslint-disable-next-line no-param-reassign |
| 166 | req.serverAccessLog.onCloseEndTime = process.hrtime.bigint(); |
| 167 | logServerAccess(req, res); |
| 168 | } |
| 169 | |
| 170 | const responseTimeInNs = Number(process.hrtime.bigint() - requestStartTime); |
| 171 | const labels = { |
| 172 | method: req.method, |
| 173 | code: res.statusCode, |
| 174 | }; |
| 175 | if (req.apiMethod) { |
| 176 | labels.action = req.apiMethod; |
| 177 | } |
| 178 | monitoringClient.httpRequestsTotal.labels(labels).inc(); |
| 179 | monitoringClient.httpRequestDurationSeconds |
| 180 | .labels(labels) |
| 181 | .observe(responseTimeInNs / 1e9); |
| 182 | monitoringClient.httpActiveRequests.dec(); |
| 183 | }; |
| 184 | res.on('close', monitorEndOfRequest); |
| 185 | |
| 186 | // use proxied hostname if needed |
nothing calls this directly
no test coverage detected