diff --git a/CHANGELOG.md b/CHANGELOG.md index 96fcb5cb..5b6f62b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Breaking ### Changed + - Changes for cluster mode + - Removed `byLabels` Grouper in `metricAggregators.js` file and created a global Map to avoid Map creation on every request for the metrics + - Moved hashing of labels from master to worker to distribute the cpu bound hashing among workers + - Workers to write metrics in tmp file and send the file name to master to read metrics from rather than sending on IPC to keep IPC congestion free. (change in `cluster.js`) ### Added diff --git a/lib/cluster.js b/lib/cluster.js index 996aff1b..b0576ada 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -219,7 +219,8 @@ function addListeners() { value["hash"] = key; }); }); - const filename = path.join(os.tmpdir(), `metrics-${process.pid}}.json`); + // adding request id in file path to handle concurrency + const filename = path.join(os.tmpdir(), `metrics-${process.pid}-${message.requestId}.json`); fs.writeFile(filename, JSON.stringify(metrics), (err) => { if(err) { process.send({