import { Server as HapiServer } from '@hapi/hapi' ; import { ProcessMetricsCollector , OsMetricsCollector , OpsMetricsCollectorOptions , ServerMetricsCollector , MetricsCollector , } from './collectors' ; import { OpsMetrics } from './types' ; export class OpsMetricsCollector implements MetricsCollector < OpsMetrics > { private readonly processCollector : ProcessMetricsCollector ; private readonly osCollector : OsMetricsCollector ; private readonly serverCollector : ServerMetricsCollector ; constructor ( server , opsOptions ) { this . processCollector = new ProcessMetricsCollector ( ) ; this . osCollector = new OsMetricsCollector ( opsOptions ) ; this . serverCollector = new ServerMetricsCollector ( server ) ; } public async collect ( ) { const [ processes , os , server ] = await Promise . all ( [ this . processCollector . collect ( ) , this . osCollector . collect ( ) , this . serverCollector . collect ( ) , ] ) ; return { collected_at : new Date ( ) , /**
             * Kibana does not yet support multi-process nodes.
             * `processes` is just an Array(1) only returning the current process's data
             *  which is why we can just use processes[0] for `process`
             */ process : processes [ 0 ] , processes , os , ... server , } ; } public reset ( ) { this . processCollector . reset ( ) ; this . osCollector . reset ( ) ; this . serverCollector . reset ( ) ; } }