Track perfs in prod
MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -40,16 +40,13 @@ export default class Logging {
// Debug DB
public static traceStart(tenantID: string, module: string, method: string): string {
- if (Utils.isDevelopmentEnv()) {
const key = `${tenantID}~${module}~${method}~${Utils.generateUUID()}`;
Logging.traceCalls[key] = new Date().getTime();
return key;
}
- }
// Debug DB
public static async traceEnd(tenantID: string, module: string, method: string, key: string, data: any = {}): Promise<void> {
- if (Utils.isDevelopmentEnv()) {
// Compute duration if provided
let executionDurationMillis: number;
let found = false;
@@ -61,7 +58,7 @@ export default class Logging {
const sizeOfDataKB = Utils.truncTo(sizeof(data) / 1024, 2);
const numberOfRecords = Array.isArray(data) ? data.length : 0;
const message = `${module}.${method} ${found ? '- ' + executionDurationMillis.toString() + 'ms' : ''} ${!Utils.isEmptyJSon(data) ? '- ' + sizeOfDataKB.toString() + 'kB' : ''} ${Array.isArray(data) ? '- ' + numberOfRecords.toString() + 'rec' : ''}`;
- console.debug(chalk.green(message));
+ Utils.isDevelopmentEnv() && console.debug(chalk.green(message));
if (sizeOfDataKB > Constants.PERF_MAX_DATA_VOLUME_KB) {
const error = new Error(`Data must be < ${Constants.PERF_MAX_DATA_VOLUME_KB}kB, got ${sizeOfDataKB}kB`);
await Logging.logWarning({
@@ -110,7 +107,6 @@ export default class Logging {
})
);
}
- }
// Log Debug
public static async logDebug(log: Log): Promise<string> {

Track perfs in prod