1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/metrics.test.js

25 lines
717 B
JavaScript
Raw Normal View History

2016-12-04 14:09:37 +01:00
'use strict';
2017-06-28 10:17:14 +02:00
const { test } = require('ava');
const { EventEmitter } = require('events');
const eventBus = new EventEmitter();
const { REQUEST_TIME } = require('./events');
const { startMonitoring } = require('./metrics');
2017-06-28 14:21:05 +02:00
const { register: prometheusRegister } = require('prom-client');
test('should collect metrics for requests', t => {
startMonitoring(true, eventBus);
2017-06-28 10:17:14 +02:00
eventBus.emit(REQUEST_TIME, {
path: 'somePath',
method: 'GET',
statusCode: 200,
time: 1337,
});
2016-12-04 14:09:37 +01:00
const metrics = prometheusRegister.metrics();
2017-06-28 10:17:14 +02:00
t.regex(
metrics,
2017-08-23 11:27:58 +02:00
/http_request_duration_milliseconds{quantile="0\.99",path="somePath",method="GET",status="200"} 1337/
2017-06-28 10:17:14 +02:00
);
2016-12-04 14:09:37 +01:00
});