Added correlation ID in trace Axios
MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -458,17 +458,6 @@ export default class Logging {
// Compute Length
const sizeOfRequestDataKB = Utils.truncTo(Utils.createDecimal(
sizeof(request)).div(1024).toNumber(), 2);
- const message = `Axios HTTP Request >> Req ${(sizeOfRequestDataKB > 0) ? sizeOfRequestDataKB : '?'} KB - ${request.method.toLocaleUpperCase()} '${request.url}'`;
- Utils.isDevelopmentEnv() && Logging.logConsoleInfo(message);
- await Logging.logDebug({
- tenantID: tenant.id,
- action: ServerAction.HTTP_REQUEST,
- module: Constants.MODULE_AXIOS, method: 'interceptor',
- message,
- detailedMessages: {
- request: Utils.cloneObject(request),
- }
- });
const performanceID = await PerformanceStorage.savePerformanceRecord(
Utils.buildPerformanceRecord({
tenantSubdomain: tenant.subdomain,
@@ -479,6 +468,17 @@ export default class Logging {
action: ServerAction.HTTP_REQUEST,
})
);
+ const message = `Axios HTTP Request - '${Utils.last5Chars(performanceID)}' >> Req ${(sizeOfRequestDataKB > 0) ? sizeOfRequestDataKB : '?'} KB - ${request.method.toLocaleUpperCase()} '${request.url}'`;
+ Utils.isDevelopmentEnv() && Logging.logConsoleInfo(message);
+ await Logging.logDebug({
+ tenantID: tenant.id,
+ action: ServerAction.HTTP_REQUEST,
+ module: Constants.MODULE_AXIOS, method: 'interceptor',
+ message,
+ detailedMessages: {
+ request: Utils.cloneObject(request),
+ }
+ });
request['performanceID'] = performanceID;
}
}
@@ -499,7 +499,7 @@ export default class Logging {
sizeOfResponseDataKB = Utils.truncTo(
Utils.createDecimal(sizeof(response.data)).div(1024).toNumber(), 2);
}
- const message = `Axios HTTP Response << ${(executionDurationMillis > 0) ? executionDurationMillis : '?'} ms - Res ${(sizeOfResponseDataKB > 0) ? sizeOfResponseDataKB : '?'} KB << ${response.config.method.toLocaleUpperCase()}/${response.status} '${response.config.url}'`;
+ const message = `Axios HTTP Response ${response.config['performanceID'] ? '- \'' + Utils.last5Chars(response.config['performanceID']) + '\' ' : ''}<< ${(executionDurationMillis > 0) ? executionDurationMillis : '?'} ms - Res ${(sizeOfResponseDataKB > 0) ? sizeOfResponseDataKB : '?'} KB << ${response.config.method.toLocaleUpperCase()}/${response.status} '${response.config.url}'`;
Utils.isDevelopmentEnv() && Logging.logConsoleInfo(message);
if (sizeOfResponseDataKB > Constants.PERF_MAX_DATA_VOLUME_KB) {
const error = new Error(`Data must be < ${Constants.PERF_MAX_DATA_VOLUME_KB}`);

Added correlation ID in trace Axios