this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 29 lines 776 B view raw
1import express from 'express'; 2import { Registry, collectDefaultMetrics } from 'prom-client'; 3 4import logger from './logger.js'; 5 6const register = new Registry(); 7collectDefaultMetrics({ register }); 8 9const app = express(); 10 11app.get('/metrics', (req, res) => { 12 register 13 .metrics() 14 .then((metrics) => { 15 res.set('Content-Type', register.contentType); 16 res.send(metrics); 17 }) 18 .catch((ex: unknown) => { 19 logger.error(`Error serving metrics: ${(ex as Error).message}`); 20 res.status(500).end((ex as Error).message); 21 }); 22}); 23 24export const startMetricsServer = (port: number, host = '127.0.0.1') => { 25 const server = app.listen(port, host, () => { 26 logger.info(`Metrics server is listening on ${host}:${port}`); 27 }); 28 return server; 29};