'use strict' ; import { Config } from '@Base/config' ; import os from 'os' ; import { Monitoring } from '@Monitoring/Monitoring' ; import { Stat } from '@Monitoring/Stat' ; import { CounterStat } from '@Monitoring/CounterStat' ; import { EventHistogram } from '@Monitoring/EventHistogram' ; export class StatsServer extends Stat { constructor ( ) { super ( 'server' , 'server' , '' ) ; const apiStat = new CounterStat ( 'apiRequests' , 'server' , 'request' ) ; if ( Config . monitoring . history ) { apiStat . AddHistogram ( 'perHour' , new EventHistogram ( 60 , 60 * 1000 ) ) ; apiStat . AddHistogram ( 'perDay' , new EventHistogram ( 24 * 12 , 5 * 60 * 1000 ) ) ; apiStat . AddHistogram ( 'perWeek' , new EventHistogram ( 7 * 24 , 60 * 60 * 1000 ) ) ; } ; Monitoring . addStat ( apiStat ) ; const apiErrors = new CounterStat ( 'apiErrors' , 'server' , 'request' ) ; if ( Config . monitoring . history ) { apiStat . AddHistogram ( 'perHour' , new EventHistogram ( 60 , 60 * 1000 ) ) ; apiStat . AddHistogram ( 'perDay' , new EventHistogram ( 24 * 12 , 5 * 60 * 1000 ) ) ; } ; Monitoring . addStat ( apiErrors ) ; } ; Event ( pCount ) { throw new Error ( 'Method not implemented.' ) ; } Gather ( ) { return ; } Report ( pReturnHistogram = true ) { return { 'apiRequests' : Monitoring . getStat ( 'apiRequests' ) ?. Report ( pReturnHistogram ) , 'apiErrors' : Monitoring . getStat ( 'apiErrors' ) ?. Report ( pReturnHistogram ) , } ; } } ;