Skip to content

Commit

Permalink
refactor(logging): Show if log entries are associated with QS Cloud o…
Browse files Browse the repository at this point in the history
…r client-managed

Implements #1279
  • Loading branch information
Göran Sander committed Oct 20, 2024
1 parent 44ca5a5 commit 6054916
Show file tree
Hide file tree
Showing 18 changed files with 606 additions and 515 deletions.
62 changes: 31 additions & 31 deletions src/lib/incident_mgmt/new_relic.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,9 @@ export async function sendReloadTaskFailureEvent(reloadParams) {
.then(async (rateLimiterRes) => {
try {
globals.logger.info(
`TASK FAILED NEWRELIC: Rate limiting check passed for failed task event. Task name: "${params.qs_taskName}"`,
`[QSEOW] TASK FAILED NEWRELIC: Rate limiting check passed for failed task event. Task name: "${params.qs_taskName}"`,
);
globals.logger.verbose(`TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
globals.logger.verbose(`[QSEOW] TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);

// Get config and needed metadata
const incidentConfig = getReloadFailedEventConfig();
Expand Down Expand Up @@ -716,26 +716,26 @@ export async function sendReloadTaskFailureEvent(reloadParams) {
return null;
} catch (err) {
if (err.message) {
globals.logger.error(`TASK FAILED NEW RELIC 1 message: ${err.message}`);
globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 1 message: ${err.message}`);
}

if (err.stack) {
globals.logger.error(`TASK FAILED NEW RELIC 1 stack: ${err.stack}`);
globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 1 stack: ${err.stack}`);
}

// If neither message nor stack is available, just log the error object
if (!err.message && !err.stack) {
globals.logger.error(`TASK FAILED NEW RELIC 1: ${JSON.stringify(err, null, 2)}`);
globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 1: ${JSON.stringify(err, null, 2)}`);
}

return null;
}
})
.catch((rateLimiterRes) => {
globals.logger.verbose(
`TASK FAILED NEWRELIC: Rate limiting failed. Not sending reload failure event to New Relic for task "${params.qs_taskName}"`,
`[QSEOW] TASK FAILED NEWRELIC: Rate limiting failed. Not sending reload failure event to New Relic for task "${params.qs_taskName}"`,
);
globals.logger.verbose(`TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
globals.logger.verbose(`[QSEOW] TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
});
}

Expand All @@ -747,9 +747,9 @@ export async function sendReloadTaskFailureLog(reloadParams) {
.then(async (rateLimiterRes) => {
try {
globals.logger.info(
`TASK FAILED NEWRELIC: Rate limiting check passed for failed task log entry. Task name: "${params.qs_taskName}"`,
`[QSEOW] TASK FAILED NEWRELIC: Rate limiting check passed for failed task log entry. Task name: "${params.qs_taskName}"`,
);
globals.logger.verbose(`TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
globals.logger.verbose(`[QSEOW] TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);

// Get config and needed metadata
const incidentConfig = getReloadFailedLogConfig();
Expand Down Expand Up @@ -832,7 +832,7 @@ export async function sendReloadTaskFailureLog(reloadParams) {
}
}
} catch (err) {
globals.logger.error(`SCRIPTLOG: ${err}`);
globals.logger.error(`[QSEOW] Get value of reload task custom property: ${err}`);
}
}

Expand All @@ -856,26 +856,26 @@ export async function sendReloadTaskFailureLog(reloadParams) {
return null;
} catch (err) {
if (err.message) {
globals.logger.error(`TASK FAILED NEW RELIC 2 message: ${err.message}`);
globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 2 message: ${err.message}`);
}

if (err.stack) {
globals.logger.error(`TASK FAILED NEW RELIC 2 stack: ${err.stack}`);
globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 2 stack: ${err.stack}`);
}

// If neither message nor stack is available, just log the error object
if (!err.message && !err.stack) {
globals.logger.error(`TASK FAILED NEW RELIC 2: ${JSON.stringify(err, null, 2)}`);
globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 2: ${JSON.stringify(err, null, 2)}`);
}

return null;
}
})
.catch((rateLimiterRes) => {
globals.logger.verbose(
`TASK FAILED NEWRELIC: Rate limiting failed. Not sending reload failure log entry to New Relic for task "${params.qs_taskName}"`,
`[QSEOW] TASK FAILED NEWRELIC: Rate limiting failed. Not sending reload failure log entry to New Relic for task "${params.qs_taskName}"`,
);
globals.logger.verbose(`TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
globals.logger.verbose(`[QSEOW] TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
});
}

Expand All @@ -887,9 +887,9 @@ export function sendReloadTaskAbortedEvent(reloadParams) {
.then(async (rateLimiterRes) => {
try {
globals.logger.info(
`TASK ABORT NEWRELIC: Rate limiting check passed for abort task event. Task name: "${params.qs_taskName}"`,
`[QSEOW] TASK ABORT NEWRELIC: Rate limiting check passed for abort task event. Task name: "${params.qs_taskName}"`,
);
globals.logger.verbose(`TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
globals.logger.verbose(`[QSEOW] TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);

// Get config and needed metadata
const incidentConfig = getReloadAbortedEventConfig();
Expand Down Expand Up @@ -974,7 +974,7 @@ export function sendReloadTaskAbortedEvent(reloadParams) {
}
}
} catch (err) {
globals.logger.error(`SCRIPTLOG: ${err}`);
globals.logger.error(`[QSEOW] Get custom property for reload task: ${err}`);
}
}

Expand All @@ -998,26 +998,26 @@ export function sendReloadTaskAbortedEvent(reloadParams) {
return null;
} catch (err) {
if (err.message) {
globals.logger.error(`TASK ABORT NEW RELIC 1 message: ${err.message}`);
globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 1 message: ${err.message}`);
}

if (err.stack) {
globals.logger.error(`TASK ABORT NEW RELIC 1 stack: ${err.stack}`);
globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 1 stack: ${err.stack}`);
}

// If neither message nor stack is available, just log the error object
if (!err.message && !err.stack) {
globals.logger.error(`TASK ABORT NEW RELIC 1: ${JSON.stringify(err, null, 2)}`);
globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 1: ${JSON.stringify(err, null, 2)}`);
}

return null;
}
})
.catch((rateLimiterRes) => {
globals.logger.verbose(
`TASK ABORT NEWRELIC: Rate limiting failed. Not sending reload aborted event to New Relic for task "${params.qs_taskName}"`,
`[QSEOW] TASK ABORT NEWRELIC: Rate limiting failed. Not sending reload aborted event to New Relic for task "${params.qs_taskName}"`,
);
globals.logger.verbose(`TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
globals.logger.verbose(`[QSEOW] TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
});
}

Expand All @@ -1029,9 +1029,9 @@ export function sendReloadTaskAbortedLog(reloadParams) {
.then(async (rateLimiterRes) => {
try {
globals.logger.info(
`TASK ABORT NEWRELIC: Rate limiting check passed for abort task log entry. Task name: "${params.qs_taskName}"`,
`[QSEOW] TASK ABORT NEWRELIC: Rate limiting check passed for abort task log entry. Task name: "${params.qs_taskName}"`,
);
globals.logger.verbose(`TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
globals.logger.verbose(`[QSEOW] TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);

// Get config and needed metadata
const incidentConfig = getReloadAbortedLogConfig();
Expand Down Expand Up @@ -1116,7 +1116,7 @@ export function sendReloadTaskAbortedLog(reloadParams) {
}
}
} catch (err) {
globals.logger.error(`SCRIPTLOG: ${err}`);
globals.logger.error(`[QSEOW] Get custom property for reload task: ${err}`);
}
}

Expand All @@ -1140,25 +1140,25 @@ export function sendReloadTaskAbortedLog(reloadParams) {
return null;
} catch (err) {
if (err.message) {
globals.logger.error(`TASK ABORT NEW RELIC 2 message: ${err.message}`);
globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 2 message: ${err.message}`);
}

if (err.stack) {
globals.logger.error(`TASK ABORT NEW RELIC 2 stack: ${err.stack}`);
globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 2 stack: ${err.stack}`);
}

// If neither message nor stack is available, just log the error object
if (!err.message && !err.stack) {
globals.logger.error(`TASK ABORT NEW RELIC 2: ${JSON.stringify(err, null, 2)}`);
globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 2: ${JSON.stringify(err, null, 2)}`);
}

return null;
}
})
.catch((rateLimiterRes) => {
globals.logger.verbose(
`TASK ABORT NEWRELIC: Rate limiting failed. Not sending reload abort log entry to New Relic for task "${params.qs_taskName}"`,
`[QSEOW] TASK ABORT NEWRELIC: Rate limiting failed. Not sending reload abort log entry to New Relic for task "${params.qs_taskName}"`,
);
globals.logger.verbose(`TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
globals.logger.verbose(`[QSEOW] TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`);
});
}
Loading

0 comments on commit 6054916

Please sign in to comment.