stats: Add metrics for all HTTP status codes
parent
1434129a7b
commit
30e5bffaf2
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const _ = require('underscore');
|
||||
const assert = require('assert').strict;
|
||||
const cookieParser = require('cookie-parser');
|
||||
const events = require('events');
|
||||
const express = require('express');
|
||||
|
@ -112,14 +113,14 @@ exports.restartServer = async () => {
|
|||
exports.server = http.createServer(app);
|
||||
}
|
||||
|
||||
// This error-handling middleware is installed first to ensure that no other middleware can
|
||||
app.use((req, res, next) => {
|
||||
// This stats logic should be in the first middleware to ensure that no other middleware can
|
||||
// prevent the stats from being updated.
|
||||
app.use((err, req, res, next) => {
|
||||
stats.meter('http500').mark();
|
||||
next(err);
|
||||
res.on('finish', () => {
|
||||
assert(res.statusCode);
|
||||
stats.meter(`http${res.statusCode}`).mark();
|
||||
});
|
||||
|
||||
app.use((req, res, next) => {
|
||||
// res.header("X-Frame-Options", "deny"); // breaks embedded pads
|
||||
if (settings.ssl) {
|
||||
// we use SSL
|
||||
|
|
Loading…
Reference in New Issue