Added group in performances logs
MODIFY
src/storage/mongodb/PerformanceStorage.ts
src/storage/mongodb/PerformanceStorage.ts
@@ -24,6 +24,7 @@ export default class PerformanceStorage {
module: performanceRecord.module,
method: performanceRecord.method,
action: performanceRecord.action,
+ group: performanceRecord.group,
};
// Add user only if provided
if (performanceRecord.userID) {

MODIFY
src/types/Performance.ts
src/types/Performance.ts
@@ -28,4 +28,22 @@ export default interface PerformanceRecord {
chargingStationID?: string;
userID?: string;
parentID?: string;
+ group?: PerformanceRecordGroup;
+}
+
+export enum PerformanceRecordGroup {
+ MONGO_DB = 'mongo-db',
+ OCPP = 'ocpp',
+ OCPI = 'ocpi',
+ OICP = 'oicp',
+ REST = 'rest',
+ GREENCOM = 'greencom',
+ STRIPE = 'stripe',
+ RECAPTCHA = 'recaptcha',
+ IOTHINK = 'iothink',
+ EV_DATABASE = 'ev-database',
+ WIT = 'wit',
+ SAP_SMART_CHARGING = 'sap-smart-charging',
+ SAP_CONCUR = 'sap-concur',
+ UNKNOWN = 'unknown',
}

MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -15,6 +15,7 @@ import LoggingStorage from '../storage/mongodb/LoggingStorage';
import { OCPIResult } from '../types/ocpi/OCPIResult';
import { OCPPStatus } from '../types/ocpp/OCPPClient';
import { OICPResult } from '../types/oicp/OICPResult';
+import { PerformanceRecordGroup } from '../types/Performance';
import PerformanceStorage from '../storage/mongodb/PerformanceStorage';
import { ServerAction } from '../types/Server';
import User from '../types/User';
@@ -100,6 +101,7 @@ export default class Logging {
await PerformanceStorage.savePerformanceRecord(
Utils.buildPerformanceRecord({
tenantID,
+ group: PerformanceRecordGroup.MONGO_DB,
durationMs: executionDurationMillis,
sizeKb: sizeOfDataKB,
source: Constants.DATABASE_SERVER,
@@ -371,6 +373,7 @@ export default class Logging {
void PerformanceStorage.savePerformanceRecord(
Utils.buildPerformanceRecord({
tenantID,
+ group: Utils.getPerformanceRecordGroupFromURL(req.url),
httpUrl: req.url,
httpCode: res.statusCode,
httpMethod: req.method,
@@ -471,6 +474,7 @@ export default class Logging {
await PerformanceStorage.savePerformanceRecord(
Utils.buildPerformanceRecord({
tenantID,
+ group: Utils.getPerformanceRecordGroupFromURL(response.config.url),
httpUrl: response.config.url,
httpCode: response.status,
httpMethod: response.config.method.toLocaleUpperCase(),
@@ -962,6 +966,7 @@ export default class Logging {
await PerformanceStorage.savePerformanceRecord(
Utils.buildPerformanceRecord({
tenantID, chargingStationID,
+ group: PerformanceRecordGroup.OCPP,
durationMs: executionDurationMillis,
source: Constants.OCPP_SERVER,
module: module, method: 'traceChargingStationActionEnd',

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -2,6 +2,7 @@ import { AnalyticsSettingsType, AssetSettingsType, BillingSettingsType, CarConne
import { Car, CarCatalog } from '../types/Car';
import { ChargePointStatus, OCPPProtocol, OCPPVersion, OCPPVersionURLPath } from '../types/ocpp/OCPPServer';
import ChargingStation, { ChargePoint, ChargingStationEndpoint, Connector, ConnectorCurrentLimitSource, CurrentType, Voltage } from '../types/ChargingStation';
+import PerformanceRecord, { PerformanceRecordGroup } from '../types/Performance';
import Transaction, { CSPhasesUsed, InactivityStatus } from '../types/Transaction';
import User, { UserRole, UserStatus } from '../types/User';
import crypto, { CipherGCMTypes } from 'crypto';
@@ -15,7 +16,6 @@ import Constants from './Constants';
import Cypher from './Cypher';
import { Decimal } from 'decimal.js';
import { ObjectID } from 'mongodb';
-import PerformanceRecord from '../types/Performance';
import QRCode from 'qrcode';
import { Request } from 'express';
import { ServerAction } from '../types/Server';
@@ -1410,9 +1410,61 @@ export default class Utils {
};
}
+ public static getPerformanceRecordGroupFromURL(url: string): PerformanceRecordGroup {
+ if (!url) {
+ return PerformanceRecordGroup.UNKNOWN;
+ }
+ // REST API
+ if (url.startsWith('/client/api/') ||
+ url.startsWith('/client/util/') ||
+ url.startsWith('/client/auth/') ||
+ url.startsWith('/v1/api/') ||
+ url.startsWith('/v1/util/') ||
+ url.startsWith('/v1/auth/')) {
+ return PerformanceRecordGroup.REST;
+ }
+ // OCPI
+ if (url.includes('ocpi')) {
+ return PerformanceRecordGroup.OCPI;
+ }
+ // Hubject
+ if (url.includes('hubject')) {
+ return PerformanceRecordGroup.OICP;
+ }
+ // Concur
+ if (url.includes('concursolutions')) {
+ return PerformanceRecordGroup.SAP_CONCUR;
+ }
+ // Recaptcha
+ if (url.includes('recaptcha')) {
+ return PerformanceRecordGroup.RECAPTCHA;
+ }
+ // Greencom
+ if (url.includes('gcn-eibp')) {
+ return PerformanceRecordGroup.GREENCOM;
+ }
+ // Stripe
+ if (url.includes('stripe')) {
+ return PerformanceRecordGroup.STRIPE;
+ }
+ // ioThink
+ if (url.includes('kheiron')) {
+ return PerformanceRecordGroup.IOTHINK;
+ }
+ // EV Database
+ if (url.includes('ev-database')) {
+ return PerformanceRecordGroup.EV_DATABASE;
+ }
+ // SAP Smart Charging
+ if (url.includes('smart-charging')) {
+ return PerformanceRecordGroup.SAP_SMART_CHARGING;
+ }
+ return PerformanceRecordGroup.UNKNOWN;
+ }
+
public static buildPerformanceRecord(params: {
- tenantID: string; durationMs: number; sizeKb?: number;
- source?: string; module: string; method: string; action: ServerAction|string;
+ tenantID: string; durationMs: number; sizeKb?: number; source?: string;
+ module: string; method: string; action: ServerAction|string; group?: PerformanceRecordGroup;
httpUrl?: string; httpMethod?: string; httpCode?: number; chargingStationID?: string,
}): PerformanceRecord {
return {
@@ -1438,6 +1490,7 @@ export default class Utils {
httpUrl: params.httpUrl,
httpMethod: params.httpMethod,
httpCode: params.httpCode,
+ group: params.group,
};
}

Added group in performances logs