From 813a5f2bd78a4def8f9c106fc03ef7df9a318f41 Mon Sep 17 00:00:00 2001 From: Markus Klose <markus.klose@student.reutlingen-university.de> Date: Thu, 24 Nov 2022 19:59:39 +0100 Subject: [PATCH] Mulitmediafile Counter added --- index.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index db4d55f..2b1e81d 100644 --- a/index.js +++ b/index.js @@ -94,21 +94,33 @@ const notSuccessfullLogIns = new client.Counter({ }); global.NOTSUCCESSFULLLOG = notSuccessfullLogIns; -const histogram = new client.Histogram({ - name: 'node_request_duration_seconds', - help: 'Own Metric: Histogram for the duration in seconds.', - buckets: [1, 2, 5, 6, 10] +const audioFileCounter = new client.Counter({ + name: 'node_audiofile_counter', + help: 'Counts the amount of times an audio file was sent' }); +const videoFileCounter = new client.Counter({ + name: 'node_videofile_counter', + help: 'Counts the amount of times a video file was sent' +}); + +const imageFileCounter = new client.Counter({ + name: 'node_imagefile_counter', + help: 'Counts the amount of times an image file was sent' +}); + + register.registerMetric(messageCounterIn); register.registerMetric(messageCounterOut); register.registerMetric(messageAll); register.registerMetric(messagePrivate); register.registerMetric(messageGroup); -register.registerMetric(histogram); register.registerMetric(successfullLogIns); register.registerMetric(notSuccessfullLogIns); register.registerMetric(clientActiveUsers); +register.registerMetric(audioFileCounter); +register.registerMetric(videoFileCounter); +register.registerMetric(imageFileCounter); app.use(bodyParser.json()); @@ -389,6 +401,7 @@ io.on('connection', (socket) => { */ io.on("connection", (socket) => { socket.on('sendImage', (file, callback) => { + imageFileCounter.inc(1); io.emit('image', file); }); }); @@ -405,6 +418,7 @@ io.on("connection", (socket) => { */ io.on("connection", (socket) => { socket.on('sendVideo', (file, callback) => { + videoFileCounter.inc(1); io.emit('video', file); }); }); @@ -421,6 +435,7 @@ io.on("connection", (socket) => { */ io.on("connection", (socket) => { socket.on('sendAudio', (file, callback) => { + audioFileCounter.inc(1); io.emit('audio', file); }); }); -- GitLab