prom-client

How to call Prometheus Histogram.observe() on serveral Functions at once in NodeJS

不羁的心 提交于 2021-02-11 15:12:16
问题 I am monitoring a NodeJS app using Prometheus. Creating a Histogram like this const histogram = new client.Histogram({ name: 'node_request_duration_seconds', help: 'Histogram for the duration in seconds.', buckets: [1, 2, 5, 6, 10] }); Now I am calling histogram.observe() like this to monitor a request to the path '/' const app = express(); app.get('/', (req, res) => { //Simulate a sleep var start = new Date() var simulateTime = 1000 setTimeout(function(argument) { // execution time simulated