Skip to content

Commit

Permalink
add worker id to metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
dhawal1248 committed Jun 24, 2024
1 parent 78b6cd4 commit fc4669f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
19 changes: 5 additions & 14 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
Expand Up @@ -103,7 +103,7 @@
"oauth-1.0a": "^2.2.6",
"object-hash": "^3.0.0",
"parse-static-imports": "^1.1.0",
"prom-client": "^15.1.2",
"prom-client": "^14.2.0",
"qs": "^6.11.1",
"rudder-transformer-cdk": "^1.4.11",
"set-value": "^4.1.0",
Expand Down
5 changes: 5 additions & 0 deletions src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ function initPyroscope() {
});
Pyroscope.start();

Check warning on line 15 in src/middleware.js

View check run for this annotation

Codecov / codecov/patch

src/middleware.js#L15

Added line #L15 was not covered by tests
Pyroscope.startHeapCollecting();
process.on('SIGINT', () => {
Pyroscope.stop();
Pyroscope.stopHeapCollecting();

Check warning on line 19 in src/middleware.js

View check run for this annotation

Codecov / codecov/patch

src/middleware.js#L17-L19

Added lines #L17 - L19 were not covered by tests
});

}

function getCPUProfile(seconds) {
Expand Down
7 changes: 6 additions & 1 deletion src/util/prometheus.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
const prometheusClient = require('prom-client');
const logger = require('../logger');
const { MetricsAggregator } = require('./metricsAggregator');
const cluster = require('cluster');

const clusterEnabled = process.env.CLUSTER_ENABLED !== 'false';
const useMetricsAggregator = process.env.USE_METRICS_AGGREGATOR === 'true';
const instanceID = process.env.INSTANCE_ID || 'localhost';
const prefix = 'transformer';
const defaultLabels = { instanceName: instanceID };
const defaultLabels = {
instanceName: instanceID,
workerId: cluster.worker ? cluster.worker.id : 0,
isMaster: cluster.isMaster
};

function appendPrefix(name) {
return `${prefix}_${name}`;
Expand Down

0 comments on commit fc4669f

Please sign in to comment.