Skip to content

Commit

Permalink
fix: improved logging (#120)
Browse files Browse the repository at this point in the history
* improved logging

* fix demux log line
  • Loading branch information
andrei-gavrilescu authored Oct 6, 2023
1 parent c86022b commit 356e675
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 4 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions src/demux.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
12 changes: 8 additions & 4 deletions src/worker-pool/WorkerPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 356e675

Please sign in to comment.