mirror of
https://github.com/wassname/talk.git
synced 2026-07-29 11:28:24 +08:00
Avoid compute metrics with 404 status code (#2587)
This commit is contained in:
committed by
Wyatt Johnson
parent
fe2d78f1f7
commit
37e39ff8c5
@@ -20,12 +20,14 @@ export const metricsRecorder = ({
|
||||
// Increment the request counter.
|
||||
httpRequestsTotal.labels(`${res.statusCode}`, req.method).inc();
|
||||
|
||||
// Add the request duration.
|
||||
httpRequestDurationMilliseconds
|
||||
.labels(req.method, req.baseUrl + req.path)
|
||||
.observe(responseTime);
|
||||
// Only compute the request path when status code isn't 404 to avoid flood
|
||||
if (res.statusCode !== 404) {
|
||||
// Add the request duration.
|
||||
httpRequestDurationMilliseconds
|
||||
.labels(req.method, req.baseUrl + req.path)
|
||||
.observe(responseTime);
|
||||
}
|
||||
});
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user