Skip to content

Commit

Permalink
aled
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed May 10, 2024
1 parent 49bc315 commit de58093
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 2 additions & 4 deletions CountItems/CountMaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CountMaster {
return next();
}),
next => {
this.metrics.start(),
this.metrics.start();
this.log.info('metrics server started', {
port: 8003,
});
Expand Down Expand Up @@ -68,9 +68,7 @@ class CountMaster {
});
return this.stop(null, () => callback(err));
}
setTimeout(() => {
return this.stop(null, () => callback());
}, 60000);
return setTimeout(() => this.stop(null, () => callback()), 60000);
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions CountItems/CountWorker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// const { collectDefaultMetrics } = require('prom-client');
const assert = require('assert');
const async = require('async');
const monitoring = require('../utils/monitoring');
const { BucketInfo } = require('arsenal').models;
const monitoring = require('../utils/monitoring');
// const registry = new Registry();
// collectDefaultMetrics({ register: registry });

Expand Down Expand Up @@ -41,7 +41,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.workersCount.inc({ state: err ? 'error' : 'success' });
callback(err, results);
});
}
Expand Down
6 changes: 4 additions & 2 deletions CountItems/masterProcess.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const werelogs = require('werelogs');
const { network } = require('arsenal');
const { reshapeExceptionError } = require('arsenal').errorUtils;
const S3UtilsMongoClient = require('../utils/S3UtilsMongoClient');

const CountMaster = require('./CountMaster');
const CountManager = require('./CountManager');
const createMongoParams = require('../utils/createMongoParams');
const createWorkers = require('./utils/createWorkers');
const { network } = require('arsenal');

const WebServer = network.http.server;
const monitoring = require('../utils/monitoring');

const logLevel = Number.parseInt(process.env.DEBUG, 10) === 1
? 'debug' : 'info';

Expand Down Expand Up @@ -37,7 +39,7 @@ const countMaster = new CountMaster({
maxConcurrent: concurrentCursors,
}),
client: new S3UtilsMongoClient(createMongoParams(log)),
metrics: new WebServer(8003, log).onRequest(monitoring.metricsHandler)
metrics: new WebServer(8003, log).onRequest(monitoring.metricsHandler),
});

const handleSignal = sig => countMaster.stop(sig, () => process.exit(0));
Expand Down
10 changes: 5 additions & 5 deletions utils/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { errors } = require('arsenal');
const promClient = require('prom-client');

const aggregatorRegistry = new promClient.AggregatorRegistry();
const collectDefaultMetrics = promClient.collectDefaultMetrics;
const { collectDefaultMetrics } = promClient;

const bucketCount = new promClient.Gauge({
name: 'bucketCount_metrics',
Expand All @@ -19,19 +19,19 @@ const bucketProcessingDuration = new promClient.Histogram({
buckets: [1, 10, 60, 600, 3600, 18000, 36000],
});

const consolidationDuration= new monitoring.Histogram({
const consolidationDuration = new promClient.Histogram({
name: 'count_items_consolidationDuration',
help: 'Duration of metrics consolidation in seconds',
labelNames: ['service'],
buckets: [0.1, 0.5, 1, 2, 5, 10],
});

const workersCount = (promClient.register.getSingleMetric('count_items_workersCountErrors')) ||
new promClient.Counter({
const workersCount = (promClient.register.getSingleMetric('count_items_workersCountErrors'))
|| new promClient.Counter({
name: 'count_items_workersCountErrors',
help: 'Number of errors in counting workers',
labelNames: ['state'],
});
});

/**
* @param {http.ServerResponse} res - http response object
Expand Down

0 comments on commit de58093

Please sign in to comment.