-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
import { PerformanceEntry, PerformanceObserver, performance } from 'perf_hooks';
import type { URL } from 'url';
import { MessageChannelUtils } from '../charging-station/MessageChannelUtils';
import { MessageType } from '../types/ocpp/MessageType';
import type { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests';
-import type { Statistics, StatisticsData, TimeSeries } from '../types/Statistics';
+import type { Statistics, TimeSeries } from '../types/Statistics';
import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from '../utils/CircularArray';
import Configuration from '../utils/Configuration';
import logger from '../utils/Logger';
name: this.objName ?? 'Object name not specified',
uri: uri.toString(),
createdAt: new Date(),
- statisticsData: new Map<string, Partial<StatisticsData>>(),
+ statisticsData: new Map(),
};
}
private initializePerformanceObserver(): void {
this.performanceObserver = new PerformanceObserver((performanceObserverList) => {
const lastPerformanceEntry = performanceObserverList.getEntries()[0];
+ // logger.debug(
+ // `${this.logPrefix()} '${lastPerformanceEntry.name}' performance entry: %j`,
+ // lastPerformanceEntry
+ // );
this.addPerformanceEntryToStatistics(lastPerformanceEntry);
- logger.debug(
- `${this.logPrefix()} '${lastPerformanceEntry.name}' performance entry: %j`,
- lastPerformanceEntry
- );
});
this.performanceObserver.observe({ entryTypes: ['measure'] });
}
this.logStatistics();
}, Configuration.getLogStatisticsInterval() * 1000);
logger.info(
- this.logPrefix() +
- ' logged every ' +
- Utils.formatDurationSeconds(Configuration.getLogStatisticsInterval())
+ `${this.logPrefix()} logged every ${Utils.formatDurationSeconds(
+ Configuration.getLogStatisticsInterval()
+ )}`
);
} else {
logger.info(
- this.logPrefix() +
- ' log interval is set to ' +
- Configuration.getLogStatisticsInterval().toString() +
- '. Not logging statistics'
+ `${this.logPrefix()} log interval is set to ${Configuration.getLogStatisticsInterval().toString()}. Not logging statistics`
);
}
}