MCPcopy Index your code
hub / github.com/scality/cloudserver / monitorEndOfRequest

Method monitorEndOfRequest

lib/server.js:163–183  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

logServerAccessFunction · 0.85

Tested by

no test coverage detected