use collectDefaultMetrics.prefix for up metric

This commit is contained in:
Konstantin Pogorelov
2024-01-06 10:48:57 +01:00
parent 407ea4b0d7
commit 0ce44722a5
2 changed files with 34 additions and 8 deletions

View File

@@ -546,15 +546,37 @@ describe('index', () => {
});
});
it('calls promClient.collectDefaultMetrics', () => {
const spy = spyOn(promClient, 'collectDefaultMetrics');
bundle({
promClient: {
collectDefaultMetrics: {
describe('option collectDefaultMetrics', () => {
it('it gets called', () => {
const spy = spyOn(promClient, 'collectDefaultMetrics');
bundle({
promClient: {
collectDefaultMetrics: {
}
}
}
});
expect(spy).toHaveBeenCalledWith({});
});
it('prefix is used for up metric', (done) => {
const instance = bundle({
promClient: {
collectDefaultMetrics: {
prefix: 'hello_'
}
}
});
const app = express();
app.use(instance);
const agent = supertest(app);
agent
.get('/metrics')
.end((err, res) => {
expect(res.status).toBe(200);
expect(res.text).toMatch(/^hello_up\s1/m);
done();
});
});
expect(spy).toHaveBeenCalledWith({});
});
describe('usage of clusterMetrics()', () => {