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
2020-02-20 08:30:51 +01:00

25 lines
716 B
JavaScript

'use strict';
const { test } = require('ava');
const { EventEmitter } = require('events');
const eventBus = new EventEmitter();
const { REQUEST_TIME } = require('./events');
const { startMonitoring } = require('./metrics');
const { register: prometheusRegister } = require('prom-client');
test('should collect metrics for requests', t => {
startMonitoring(true, eventBus);
eventBus.emit(REQUEST_TIME, {
path: 'somePath',
method: 'GET',
statusCode: 200,
time: 1337,
});
const metrics = prometheusRegister.metrics();
t.regex(
metrics,
/http_request_duration_milliseconds{quantile="0.99",status="200",method="GET",path="somePath"} 1337/
);
});