'use strict' ; import { Config } from '@Base/config' ; import { Stat } from '@Monitoring/Stat' ; import { StatsOs } from '@Monitoring/StatsOs' ; import { StatsMetaverse } from '@Monitoring/StatsMetaverse' ; import { StatsServer } from '@Monitoring/StatsServer' ; import { Logger } from '@Tools/Logging' ; let _statistics ; export function initMonitoring ( ) { _statistics = new Map < string , Stat > ( ) ; if ( Config . monitoring . enable ) { CreateStats ( ) ; setInterval ( async ( ) => { for ( const stat of _statistics . values ( ) ) { await stat . Gather ( ) ; } ; } , 1000 * 1 ) ; } ; } ; export const Monitoring = { addStat ( pStat ) { _statistics . set ( pStat . name , pStat ) ; } , getStat ( pStatName ) { return _statistics . get ( pStatName ) ; } , getStats ( ) { return _statistics . values ( ) ; } , event ( pEventName , pCount = 1 ) { const theStat = _statistics ?. get ( pEventName ) ; if ( theStat ) { theStat . Event ( pCount ) ; } ; } } ; function CreateStats ( ) { Monitoring . addStat ( new StatsOs ( ) ) ; Monitoring . addStat ( new StatsMetaverse ( ) ) ; Monitoring . addStat ( new StatsServer ( ) ) ; } ;