Skip to content

Commit

Permalink
fixups post reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed May 15, 2024
1 parent a50c483 commit 094b51c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 0 additions & 2 deletions CountItems/CountMaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class CountMaster {
this.log = params.log;
this.manager = params.manager;
this.client = params.client;
CountMaster.waitingForPromScraping = false;
}

stop(signal, callback) {
Expand Down Expand Up @@ -59,7 +58,6 @@ class CountMaster {
});
return this.stop(null, () => callback(err));
}
CountMaster.waitingForPromScraping = true;
return callback();
});
}
Expand Down
2 changes: 1 addition & 1 deletion CountItems/CountWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CountWorker {
next => this.client._getIsTransient(bucketInfo, this.log, next),
(isTransient, next) => this.client.getObjectMDStats(bucketName, bucketInfo, isTransient, this.log, next),
], (err, results) => {
monitoring.workersCount.inc({ state: err ? 'error' : 'success' });
monitoring.bucketsCount.inc({ status: err ? 'error' : 'success' });
callback(err, results);
});
}
Expand Down
15 changes: 9 additions & 6 deletions CountItems/masterProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ const loggerConfig = {
dump: 'error',
};

let waitingForPromScraping = false;

werelogs.configure(loggerConfig);
const log = new werelogs.Logger('S3Utils::CountItems::Master');

const prometheusPollingFrequency = process.env.PROMETHEUS_POLLING_FREQUENCY && !Number.isNaN(process.env.PROMETHEUS_POLLING_FREQUENCY)
? Number.parseInt(process.env.PROMETHEUS_POLLING_FREQUENCY, 10)
const prometheusPollingPeriod = Number.parseInt(process.env.PROMETHEUS_POLLING_PERIOD, 10) > 0
? Number.parseInt(process.env.PROMETHEUS_POLLING_PERIOD, 10)
: 30;

const promtheusPollingThreshold = process.env.PROMETHEUS_POLLING_THRESHOLD && !Number.isNaN(process.env.PROMETHEUS_POLLING_THRESHOLD)
? Number.parseInt(process.env.PROMETHEUS_POLLING_THRESHOLD, 10)
const promtheusPollingAttempts = Number.parseInt(process.env.PROMETHEUS_POLLING_ATTEMPTS, 10) > 0
? Number.parseInt(process.env.PROMETHEUS_POLLING_ATTEMPTS, 10)
: 5;

const numWorkers = process.env.NUM_WORKERS && !Number.isNaN(process.env.NUM_WORKERS)
Expand All @@ -51,7 +53,7 @@ const countMaster = new CountMaster({

const metricServer = new WebServer(8003, log).onRequest((req, res) => monitoring.metricsHandler(
() => {
if (CountMaster.waitingForPromScraping === true) {
if (waitingForPromScraping === true) {
countMaster.stop(null, () => process.exit(1));
}
},
Expand All @@ -76,7 +78,8 @@ countMaster.start(err => {
if (err) {
process.exit(1);
}
waitingForPromScraping = true;
setTimeout(() => {
countMaster.stop(null, () => process.exit(0));
}, promtheusPollingThreshold * prometheusPollingFrequency * 1000 * 4);
}, promtheusPollingAttempts * prometheusPollingPeriod * 1000 * 4);
});
6 changes: 3 additions & 3 deletions utils/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const consolidationDuration = new promClient.Histogram({
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10],
});

const workersCount = new promClient.Counter({
const bucketsCount = new promClient.Counter({
name: 's3_countitems_total_buckets_count',
help: 'Buckets processed by workers state',
labelNames: ['state'],
labelNames: ['status'],
});

const objectsCount = new promClient.Counter({
Expand Down Expand Up @@ -83,6 +83,6 @@ module.exports = {
metricsHandler,
bucketProcessingDuration,
consolidationDuration,
workersCount,
bucketsCount,
objectsCount,
};

0 comments on commit 094b51c

Please sign in to comment.