Added charging station ID in perfs logs
MODIFY
src/storage/mongodb/PerformanceStorage.ts
src/storage/mongodb/PerformanceStorage.ts
@@ -51,6 +51,10 @@ export default class PerformanceStorage {
performanceRecordMDB.httpCode = Utils.convertToInt(performanceRecord.httpCode);
performanceRecordMDB.httpUrl = performanceRecord.httpUrl;
}
+ // Add Charging Station
+ if (performanceRecord.chargingStationID) {
+ performanceRecordMDB.chargingStationID = performanceRecord.chargingStationID;
+ }
// Insert
await global.database.getCollection<any>(Constants.DEFAULT_TENANT, 'performances')
.insertOne(performanceRecordMDB);

MODIFY
src/types/Performance.ts
src/types/Performance.ts
@@ -25,6 +25,7 @@ export default interface PerformanceRecord {
httpUrl?: string;
httpMethod?: string;
httpCode?: number;
+ chargingStationID?: string;
userID?: string;
parentID?: string;
}

MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -914,17 +914,17 @@ export default class Logging {
});
}
- private static async traceChargingStationActionEnd(module: string, tenantID: string, chargeBoxID: string,
+ private static async traceChargingStationActionEnd(module: string, tenantID: string, chargingStationID: string,
action: ServerAction, detailedMessages: any, direction: '<<'|'>>'): Promise<void> {
// Compute duration if provided
let executionDurationMillis: number;
let found = false;
- if (Logging.traceCalls[`${chargeBoxID}~action`]) {
- executionDurationMillis = (new Date().getTime() - Logging.traceCalls[`${chargeBoxID}~action`]);
- delete Logging.traceCalls[`${chargeBoxID}~action`];
+ if (Logging.traceCalls[`${chargingStationID}~action`]) {
+ executionDurationMillis = (new Date().getTime() - Logging.traceCalls[`${chargingStationID}~action`]);
+ delete Logging.traceCalls[`${chargingStationID}~action`];
found = true;
}
- const message = `${direction} OCPP Request '${action}' on '${chargeBoxID}' has been processed ${found ? 'in ' + executionDurationMillis.toString() + 'ms' : ''}`;
+ const message = `${direction} OCPP Request '${action}' on '${chargingStationID}' has been processed ${found ? 'in ' + executionDurationMillis.toString() + 'ms' : ''}`;
Utils.isDevelopmentEnv() && console.debug(chalk.green(message));
if (executionDurationMillis > Constants.PERF_MAX_RESPONSE_TIME_MILLIS) {
const error = new Error(`Execution must be < ${Constants.PERF_MAX_RESPONSE_TIME_MILLIS}ms, got ${executionDurationMillis}ms`);
@@ -947,21 +947,21 @@ export default class Logging {
if (detailedMessages && detailedMessages['status'] && detailedMessages['status'] === OCPPStatus.REJECTED) {
await Logging.logError({
tenantID,
- source: chargeBoxID,
+ source: chargingStationID,
module, method: action, action,
message, detailedMessages
});
} else {
await Logging.logDebug({
tenantID,
- source: chargeBoxID,
+ source: chargingStationID,
module, method: action, action,
message, detailedMessages
});
}
await PerformanceStorage.savePerformanceRecord(
Utils.buildPerformanceRecord({
- tenantID,
+ tenantID, chargingStationID,
durationMs: executionDurationMillis,
source: Constants.OCPP_SERVER,
module: module, method: 'traceChargingStationActionEnd',

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -1413,7 +1413,7 @@ export default class Utils {
public static buildPerformanceRecord(params: {
tenantID: string; durationMs: number; sizeKb?: number;
source?: string; module: string; method: string; action: ServerAction|string;
- httpUrl?: string; httpMethod?: string; httpCode?: number;
+ httpUrl?: string; httpMethod?: string; httpCode?: number; chargingStationID?: string,
}): PerformanceRecord {
return {
tenantID: params.tenantID,
@@ -1434,6 +1434,7 @@ export default class Utils {
module: params.module,
method: params.method,
action: params.action,
+ chargingStationID: params.chargingStationID,
httpUrl: params.httpUrl,
httpMethod: params.httpMethod,
httpCode: params.httpCode,

Added charging station ID in perfs logs