1
0
mirror of https://github.com/whippyshou/mastodon synced 2024-11-27 22:38:35 +09:00

Add metrics endpoint to streaming API (#23388)

This commit is contained in:
Eugen Rochko 2023-02-03 21:29:23 +01:00 committed by GitHub
parent 79ca19e9b2
commit 01584f03e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -850,6 +850,18 @@ const startWorker = async (workerId) => {
res.end('OK'); res.end('OK');
}); });
app.get('/metrics', (req, res) => server.getConnections((err, count) => {
res.writeHeader(200, { 'Content-Type': 'application/openmetrics-text; version=1.0.0; charset=utf-8' });
res.write('# TYPE connected_clients gauge\n');
res.write('# HELP connected_clients The number of clients connected to the streaming server\n');
res.write(`connected_clients ${count}.0\n`);
res.write('# TYPE connected_channels gauge\n');
res.write('# HELP connected_channels The number of Redis channels the streaming server is subscribed to\n');
res.write(`connected_channels ${Object.keys(subs).length}.0\n`);
res.write('# EOF\n');
res.end();
}));
app.use(authenticationMiddleware); app.use(authenticationMiddleware);
app.use(errorMiddleware); app.use(errorMiddleware);