mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-01-18 16:27:28 +01:00
minor codestyle fixes, turn async/await in metricsApp into a conventional promise
This commit is contained in:
4
Makefile
4
Makefile
@@ -3,8 +3,8 @@
|
|||||||
test:
|
test:
|
||||||
npm test
|
npm test
|
||||||
lint:
|
lint:
|
||||||
node_modules/eslint/bin/eslint.js src
|
npx eslint src
|
||||||
node_modules/.bin/dtslint types
|
npm run dtslint-next
|
||||||
coverage:
|
coverage:
|
||||||
node_modules/istanbul/lib/cli.js cover \
|
node_modules/istanbul/lib/cli.js cover \
|
||||||
-i 'src/*' \
|
-i 'src/*' \
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ describe('index', () => {
|
|||||||
bypass: (req)=> {
|
bypass: (req)=> {
|
||||||
// metrics added here to attempt skipping /metrics
|
// metrics added here to attempt skipping /metrics
|
||||||
// this should fail though, because serving /metrics preceeds bypassing
|
// this should fail though, because serving /metrics preceeds bypassing
|
||||||
return !!req.url.match(/test|bad.word|metrics/)
|
return !!req.url.match(/test|bad.word|metrics/);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.use(instance);
|
app.use(instance);
|
||||||
@@ -512,18 +512,18 @@ describe('index', () => {
|
|||||||
|
|
||||||
describe('usage of clusterMetrics()', () => {
|
describe('usage of clusterMetrics()', () => {
|
||||||
it('clusterMetrics returns 200 even without a cluster', (done) => {
|
it('clusterMetrics returns 200 even without a cluster', (done) => {
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
cluster.workers = [];
|
cluster.workers = [];
|
||||||
|
|
||||||
app.use('/cluster_metrics', bundle.clusterMetrics());
|
app.use('/cluster_metrics', bundle.clusterMetrics());
|
||||||
const agent = supertest(app);
|
const agent = supertest(app);
|
||||||
agent
|
agent
|
||||||
.get('/cluster_metrics')
|
.get('/cluster_metrics')
|
||||||
.end((err, res) => {
|
.end((err, res) => {
|
||||||
expect(res.status).toBe(200);
|
expect(res.status).toBe(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('clusterMetrics returns 500 in case of an error', (done) => {
|
it('clusterMetrics returns 500 in case of an error', (done) => {
|
||||||
|
|||||||
@@ -206,9 +206,10 @@ function main(opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (opts.metricsApp) {
|
if (opts.metricsApp) {
|
||||||
opts.metricsApp.get(opts.metricsPath || '/metrics', async (req, res, next) => {
|
opts.metricsApp.get(opts.metricsPath || '/metrics', (req, res) => {
|
||||||
res.set('Content-Type', opts.promRegistry.contentType);
|
res.set('Content-Type', opts.promRegistry.contentType);
|
||||||
return res.end(await opts.promRegistry.metrics());
|
opts.promRegistry.metrics()
|
||||||
|
.then(metrics => res.end(metrics));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user