MessageType,
type RequestCommand,
type Statistics,
+ type StatisticsData,
type StorageConfiguration,
type TimestampedData
} from '../types/index.js'
objName: string | undefined,
uri: URL | undefined
): PerformanceStatistics | undefined {
- const logPfx = logPrefix(' Performance statistics')
if (objId == null) {
const errMsg = 'Cannot get performance statistics instance without specifying object id'
- logger.error(`${logPfx} ${errMsg}`)
+ logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`)
throw new BaseError(errMsg)
}
if (objName == null) {
const errMsg = 'Cannot get performance statistics instance without specifying object name'
- logger.error(`${logPfx} ${errMsg}`)
+ logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`)
throw new BaseError(errMsg)
}
if (uri == null) {
const errMsg = 'Cannot get performance statistics instance without specifying object uri'
- logger.error(`${logPfx} ${errMsg}`)
+ logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`)
throw new BaseError(errMsg)
}
if (!PerformanceStatistics.instances.has(objId)) {
return PerformanceStatistics.instances.get(objId)
}
+ public static deleteInstance (objId: string | undefined): boolean {
+ if (objId == null) {
+ const errMsg = 'Cannot delete performance statistics instance without specifying object id'
+ logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`)
+ throw new BaseError(errMsg)
+ }
+ return PerformanceStatistics.instances.delete(objId)
+ }
+
public static beginMeasure (id: string): string {
const markId = `${id.charAt(0).toUpperCase()}${id.slice(1)}~${generateUUID()}`
performance.mark(markId)
private logStatistics (): void {
logger.info(this.logPrefix(), {
...this.statistics,
- statisticsData: JSONStringifyWithMapSupport(this.statistics.statisticsData)
+ statisticsData: JSON.parse(
+ JSONStringifyWithMapSupport(this.statistics.statisticsData)
+ ) as Map<string | RequestCommand | IncomingRequestCommand, StatisticsData>
})
}
}
}
+ private static readonly logPrefix = (): string => {
+ return logPrefix(' Performance statistics')
+ }
+
private readonly logPrefix = (): string => {
return logPrefix(` ${this.objName} | Performance statistics`)
}