From 356e675a5fd9e97f2aca369c4259f9c81c45185f Mon Sep 17 00:00:00 2001 From: Andrei Gavrilescu <51706180+andrei-gavrilescu@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:08:20 +0300 Subject: [PATCH] fix: improved logging (#120) * improved logging * fix demux log line --- package-lock.json | 4 ++-- package.json | 2 +- src/app.js | 6 ++++-- src/demux.js | 4 ++-- src/worker-pool/WorkerPool.js | 12 ++++++++---- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index a32320e3..f86452e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rtcstats-server", - "version": "2.24.1", + "version": "2.24.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rtcstats-server", - "version": "2.24.1", + "version": "2.24.3", "license": "ISC", "dependencies": { "amplitude": "^4.0.1", diff --git a/package.json b/package.json index 3dd8efbc..1c4d5d29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rtcstats-server", - "version": "2.24.1", + "version": "2.24.3", "description": "The rtcstats-server represents the server side component of the rtcstats ecosystem, the client side being https://github.com/jitsi/rtcstats which collects and sends WebRTC related statistics.", "main": "websocket.js", "private": true, diff --git a/src/app.js b/src/app.js index 75e381f9..7003ae88 100644 --- a/src/app.js +++ b/src/app.js @@ -317,8 +317,6 @@ function wsConnectionHandler(client, upgradeReq) { const demuxSink = new DemuxSink(demuxSinkOptions); demuxSink.on('close-sink', ({ id, meta }) => { - logger.info('[App] Queue for processing id %s', id); - const { confID = '' } = meta; const tenantInfo = extractTenantDataFromUrl(confID); @@ -344,6 +342,10 @@ function wsConnectionHandler(client, upgradeReq) { ...tenantInfo }; + const obfuscatedDumpData = obfuscatePII(dumpData); + + logger.info('[App] Processing dump id %s, metadata %o', id, obfuscatedDumpData); + // Don't process dumps generated by JVB & Jigasi, there should be a more formal process to if (config.features.disableFeatExtraction || connectionInfo.clientProtocol?.includes('JVB') diff --git a/src/demux.js b/src/demux.js index 47412b41..3d23f196 100644 --- a/src/demux.js +++ b/src/demux.js @@ -112,8 +112,8 @@ class DemuxSink extends Writable { * @param {string} id - UniqueId associated with the sink * @param {WriteStream} sink - Opened file writable stream associated with the id */ - _sinkClose({ id, sink, meta }) { - this.log.info('[Demux] close-sink %s, metadata: %o', id, meta); + _sinkClose({ id, sink }) { + this.log.info('[Demux] close-sink %s', id); sink.end(); } diff --git a/src/worker-pool/WorkerPool.js b/src/worker-pool/WorkerPool.js index 87ceec95..2298b98c 100644 --- a/src/worker-pool/WorkerPool.js +++ b/src/worker-pool/WorkerPool.js @@ -4,7 +4,7 @@ const { Worker } = require('worker_threads'); const logger = require('../logging'); const PromCollector = require('../metrics/PromCollector'); -const { ResponseType, obfuscatePII } = require('../utils/utils'); +const { ResponseType } = require('../utils/utils'); const WorkerStatus = Object.freeze({ IDLE: 'IDLE', @@ -131,10 +131,14 @@ class WorkerPool extends EventEmitter { * @param {*} task */ _processTask(workerMeta, task) { - const { body = {} } = task; - const obfuscatedBody = obfuscatePII(body); + const { body = {}, body: { clientId = '' } = {} } = task; + + logger.info( + '[WorkerPool] Processing task with clientId %s, current queue size %d', + clientId, + this.taskQueue.length + ); - logger.info('[WorkerPool] Processing task %o, current queue size %d', obfuscatedBody, this.taskQueue.length); workerMeta.currentTaskMeta = body; workerMeta.worker.postMessage(task); workerMeta.status = WorkerStatus.RUNNING;