mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
stats: Add metrics for all HTTP status codes
This commit is contained in:
parent
1434129a7b
commit
30e5bffaf2
1 changed files with 8 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
const assert = require('assert').strict;
|
||||||
const cookieParser = require('cookie-parser');
|
const cookieParser = require('cookie-parser');
|
||||||
const events = require('events');
|
const events = require('events');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
@ -112,14 +113,14 @@ exports.restartServer = async () => {
|
||||||
exports.server = http.createServer(app);
|
exports.server = http.createServer(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This error-handling middleware is installed first 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);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
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.
|
||||||
|
res.on('finish', () => {
|
||||||
|
assert(res.statusCode);
|
||||||
|
stats.meter(`http${res.statusCode}`).mark();
|
||||||
|
});
|
||||||
|
|
||||||
// res.header("X-Frame-Options", "deny"); // breaks embedded pads
|
// res.header("X-Frame-Options", "deny"); // breaks embedded pads
|
||||||
if (settings.ssl) {
|
if (settings.ssl) {
|
||||||
// we use SSL
|
// we use SSL
|
||||||
|
|
Loading…
Reference in a new issue