Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logperf2 #4019

Draft
wants to merge 10 commits into
base: master-qa
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"tslib": "^2.4.0",
"tz-lookup": "^6.1.25",
"urlencode": "^1.1.0",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.10.0",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.15.0",
"validator": "^13.7.0",
"ws": "^8.10.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/AsyncTaskBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class AsyncTaskBuilder {
// Save
await AsyncTaskStorage.saveAsyncTask(asyncTask as AsyncTask);
// Log
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'createAndSaveAsyncTasks',
Expand Down
14 changes: 7 additions & 7 deletions src/async-task/AsyncTaskManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class AsyncTaskManager {

public static async handleAsyncTasks(): Promise<void> {
let failedToAcquireLock = false;
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand All @@ -75,7 +75,7 @@ export default class AsyncTaskManager {
{ status: AsyncTaskStatus.PENDING }, Constants.DB_PARAMS_MAX_LIMIT);
// Process them
if (!Utils.isEmptyArray(asyncTasks.result)) {
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand All @@ -98,7 +98,7 @@ export default class AsyncTaskManager {
asyncTask.lastChangedOn = asyncTask.execTimestamp;
await AsyncTaskStorage.saveAsyncTask(asyncTask);
// Log
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand All @@ -115,7 +115,7 @@ export default class AsyncTaskManager {
await AsyncTaskStorage.saveAsyncTask(asyncTask);
processedTask.inSuccess++;
// Log
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand All @@ -130,7 +130,7 @@ export default class AsyncTaskManager {
asyncTask.lastChangedOn = new Date();
await AsyncTaskStorage.saveAsyncTask(asyncTask);
// Log error
await Logging.logError({
Logging.beError()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
module: MODULE_NAME, method: 'handleAsyncTasks',
action: ServerAction.ASYNC_TASK,
Expand Down Expand Up @@ -162,7 +162,7 @@ export default class AsyncTaskManager {
void AsyncTaskManager.handleAsyncTasks();
}
} else {
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand Down Expand Up @@ -201,7 +201,7 @@ export default class AsyncTaskManager {
case AsyncTasks.OCPI_PUSH_EVSE_STATUSES:
return new OCPIPushEVSEStatusesAsyncTask(asyncTask, correlationID);
default:
await Logging.logError({
Logging.beError()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand Down
16 changes: 8 additions & 8 deletions src/async-task/TenantAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
(taskSettings.task.disableAllTasks || !Utils.isEmptyArray(taskSettings.task.disableTasksInEnv) && taskSettings.task.disableTasksInEnv.includes(currentTaskEnv))) {
// Tasks are disabled for this environment
isTaskExecutionDisabled = true;
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -43,7 +43,7 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
}
// Check if tenant task needs to run on a specific env
if (tenant.taskExecutionEnv && tenant.taskExecutionEnv !== currentTaskEnv) {
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -54,13 +54,13 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
}
const tenantCorrelationID = Utils.generateShortNonUniqueID();
const startTimeInTenant = moment();
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
message: `The Task '${this.getAsyncTask().name}~${this.getCorrelationID()}~${tenantCorrelationID}' is running for Tenant ${Utils.buildTenantName(tenant)}...`
});
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: tenant.id,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -74,14 +74,14 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
// Hook
await this.afterExecuteTenantAsyncTask(tenant);
} catch (error) {
await Logging.logError({
Logging.beError()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
message: `Error while running the Task '${this.getAsyncTask().name}~${this.getCorrelationID()}~${tenantCorrelationID}' for Tenant ${Utils.buildTenantName(tenant)}: ${error.message as string}`,
detailedMessages: { error: error.stack }
});
await Logging.logError({
Logging.beError()?.log({
tenantID: tenant.id,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -91,13 +91,13 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
}
// Log Total Processing Time in Tenant
const totalTimeSecsInTenant = moment.duration(moment().diff(startTimeInTenant)).asSeconds();
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
message: `The Task '${this.getAsyncTask().name}~${this.getCorrelationID()}~${tenantCorrelationID}' has been run successfully in ${totalTimeSecsInTenant} secs for Tenant ${Utils.buildTenantName(tenant)}`
});
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: tenant.id,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/BillTransactionAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class BillTransactionAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.BILLING_TRANSACTION, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.BILLING_TRANSACTION, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ImportHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default class ImportHelper {
await UserStorage.addSiteToUser(tenant, user.id, importedSiteID);
} else {
// Site does not exist
await Logging.logError({
Logging.beError()?.log({
tenantID: tenant.id,
action: ServerAction.USERS_IMPORT,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/SynchronizeCarCatalogsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class SynchronizeCarCatalogsAsyncTask extends AbstractAsyncTask {
await carDatabaseImpl.synchronizeCarCatalogs();
} catch (error) {
// Log error
await Logging.logActionExceptionMessage(Constants.DEFAULT_TENANT_ID, ServerAction.SYNCHRONIZE_CAR_CATALOGS, error);
Logging.logActionExceptionMessage(Constants.DEFAULT_TENANT_ID, ServerAction.SYNCHRONIZE_CAR_CATALOGS, error);
} finally {
// Release the lock
await LockingManager.release(syncCarCatalogsLock);
Expand Down
8 changes: 4 additions & 4 deletions src/async-task/tasks/TagsImportAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class TagsImportAsyncTask extends AbstractAsyncTask {
// Get total number of Tags to import
const totalTagsToImport = await TagStorage.getImportedTagsCount(tenant);
if (totalTagsToImport > 0) {
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: tenant.id,
action: ServerAction.TAGS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -66,7 +66,7 @@ export default class TagsImportAsyncTask extends AbstractAsyncTask {
importedTag.errorDescription = error.message;
result.inError++;
await TagStorage.saveImportedTag(tenant, importedTag);
await Logging.logError({
Logging.beError()?.log({
tenantID: tenant.id,
action: ServerAction.TAGS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -77,7 +77,7 @@ export default class TagsImportAsyncTask extends AbstractAsyncTask {
}
if (!Utils.isEmptyArray(importedTags.result) && (result.inError + result.inSuccess) > 0) {
const intermediateDurationSecs = Math.round((new Date().getTime() - startTime) / 1000);
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: tenant.id,
action: ServerAction.TAGS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -95,7 +95,7 @@ export default class TagsImportAsyncTask extends AbstractAsyncTask {
);
} catch (error) {
// Log error
await Logging.logActionExceptionMessage(tenant.id, ServerAction.TAGS_IMPORT, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.TAGS_IMPORT, error);
} finally {
// Release the lock
await LockingManager.release(importTagsLock);
Expand Down
8 changes: 4 additions & 4 deletions src/async-task/tasks/UsersImportAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
// Get total number of Users to import
const totalUsersToImport = await UserStorage.getImportedUsersCount(tenant);
if (totalUsersToImport > 0) {
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: tenant.id,
action: ServerAction.USERS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -66,7 +66,7 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
result.inError++;
// Update it
await UserStorage.saveImportedUser(tenant, importedUser);
await Logging.logError({
Logging.beError()?.log({
tenantID: tenant.id,
action: ServerAction.USERS_IMPORT,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -77,7 +77,7 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
}
if (importedUsers.result.length > 0 && (result.inError + result.inSuccess) > 0) {
const intermediateDurationSecs = Math.round((new Date().getTime() - startTime) / 1000);
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: tenant.id,
action: ServerAction.USERS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -95,7 +95,7 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
);
} catch (error) {
// Log error
await Logging.logActionExceptionMessage(tenant.id, ServerAction.USERS_IMPORT, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.USERS_IMPORT, error);
} finally {
// Release the lock
await LockingManager.release(importUsersLock);
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPICheckCdrsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPICheckCdrsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_CDRS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_CDRS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPICheckLocationsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPICheckLocationsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_LOCATIONS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_LOCATIONS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPICheckSessionsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPICheckSessionsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_SESSIONS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_SESSIONS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPullCdrsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPullCdrsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_CDR, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_CDR, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPullLocationsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPullLocationsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_LOCATIONS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_LOCATIONS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPullSessionsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPullSessionsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_SESSION, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_SESSION, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPullTokensAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPullTokensAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_GET_TOKENS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_GET_TOKENS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPushEVSEStatusesAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPushEVSEStatusesAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_UPDATE_STATUS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_UPDATE_STATUS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPushTokensAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class OCPIPushTokensAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_UPDATE_TOKENS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_UPDATE_TOKENS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/authorization/Authorizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ export default class Authorizations {
if (remoteAuthorization && OCPIUtils.isAuthorizationValid(remoteAuthorization.timestamp)) {
// Check Tag ID
if (remoteAuthorization.tagId === tag.ocpiToken?.uid) {
await Logging.logDebug({
Logging.beDebug()?.log({
...LoggingHelper.getChargingStationProperties(chargingStation),
tenantID: tenant.id, action,
message: `${Utils.buildConnectorInfo(connector.connectorId, transaction?.id)} Valid Remote Authorization found for Tag ID '${tag.ocpiToken.uid}'`,
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/LocalCarCatalogBootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class LocalCarCatalogBootstrap {
created++;
} catch (error) {
const message = `Error while importing the local Car ID '${carCatalog.id}': ${error.message as string}`;
await Logging.logError({
Logging.beError()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.UPDATE_LOCAL_CAR_CATALOGS,
module: MODULE_NAME, method: 'uploadLocalCarCatalogsFromFile',
Expand All @@ -66,7 +66,7 @@ export default class LocalCarCatalogBootstrap {
}
} catch (error) {
const message = `Error while importing the local Cars: ${error.message as string}`;
await Logging.logError({
Logging.beError()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.UPDATE_LOCAL_CAR_CATALOGS,
module: MODULE_NAME, method: 'uploadLocalCarCatalogsFromFile',
Expand All @@ -77,7 +77,7 @@ export default class LocalCarCatalogBootstrap {
// Log in the default tenant
if (created > 0) {
const message = `${created} local Car(s) catalog created in the default tenant`;
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.UPDATE_LOCAL_CAR_CATALOGS,
message, module: MODULE_NAME, method: 'uploadLocalCarCatalogsFromFile',
Expand Down
Loading