diff --git a/lib/monitor.js b/lib/monitor.js index 6a14015..17c6a7e 100755 --- a/lib/monitor.js +++ b/lib/monitor.js @@ -7,6 +7,7 @@ const Os = require('os'); const Hoek = require('hoek'); const Oppsy = require('oppsy'); const Pumpify = require('pumpify'); +const { pipeline } = require('stream'); const Package = require('../package.json'); const Utils = require('./utils'); @@ -122,11 +123,18 @@ class Monitor { streamObjs.unshift(new Utils.NoOp()); } - this._reporters.set(reporterName, Pumpify.obj(streamObjs)).get(reporterName).on('error', (err) => { + const combinedStreamErrHandler = (err) => { + if (err) { + console.error(`There was a problem (${err}) in ${reporterName} and it has been destroyed.`); + console.error(err); + } + } - console.error(`There was a problem (${err}) in ${reporterName} and it has been destroyed.`); - console.error(err); - }); + const combinedStream = pipeline + ? pipeline(...streamObjs, combinedStreamErrHandler) + : Pumpify.obj(streamObjs).on('error', combinedStreamErrHandler); + + this._reporters.set(reporterName, combinedStream); }); this._state.report = true; diff --git a/package.json b/package.json index 83571e3..7d9a98f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@elastic/good", "description": "Server and process monitoring plugin", - "version": "8.1.1-kibana1", + "version": "8.1.1-kibana2", "repository": "git://github.com/elastic/good", "main": "lib/index.js", "keywords": [