split includeCustomLabels into customLabels and transformLabels

This commit is contained in:
Konstantin Pogorelov
2017-09-23 12:03:23 +02:00
parent 8318e0ec1d
commit a261ab76a3
2 changed files with 36 additions and 33 deletions

View File

@@ -258,10 +258,10 @@ describe('index', () => {
});
});
it('includeCustomLabels={foo: "bar"} adds foo="bar" label to metrics', done => {
it('customLabels={foo: "bar"} adds foo="bar" label to metrics', done => {
const app = express();
const instance = bundle({
includeCustomLabels: {foo: "bar"}
customLabels: {foo: 'bar'}
});
app.use(instance);
app.use('/test', (req, res) => res.send('it worked'));
@@ -279,6 +279,33 @@ describe('index', () => {
});
});
it('tarnsformLabels can set label values', done => {
const app = express();
const instance = bundle({
includePath: true,
customLabels: {foo: 'bar'},
transformLabels: labels => {
labels.foo = 'baz';
labels.path += '/ok';
}
});
app.use(instance);
app.use('/test', (req, res) => res.send('it worked'));
const agent = supertest(app);
agent
.get('/test')
.end(() => {
agent
.get('/metrics')
.end((err, res) => {
expect(res.status).toBe(200);
expect(res.text).toMatch(/foo="baz"/);
expect(res.text).toMatch(/path="\/test\/ok"/);
done();
});
});
});
it('Koa: metrics returns up=1', done => {
const app = new Koa();
const bundled = bundle({