Once the buffer has any events, the collector is always ready (#36995) (#46379)

This commit is contained in:
Chris Roberson 2019-09-23 15:47:23 -04:00 committed by GitHub
parent 281e2fe50c
commit 54c73e2f76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,6 +13,7 @@ import { opsBuffer } from './ops_buffer';
import Oppsy from 'oppsy';
import { cloneDeep } from 'lodash';
let bufferHadEvents = false;
class OpsMonitor {
constructor(server, buffer, interval) {
@ -80,7 +81,12 @@ export function getOpsStatsCollector(server, kbnServer) {
return collectorSet.makeStatsCollector({
type: KIBANA_STATS_TYPE_MONITORING,
init: opsMonitor.start,
isReady: () => buffer.hasEvents(),
isReady: () => {
if (!bufferHadEvents) {
bufferHadEvents = buffer.hasEvents();
}
return bufferHadEvents;
},
fetch: async () => {
return await buffer.flush();
}