refactor(core): Revamp logs for scaling mode (#11244)

This commit is contained in:
Iván Ovejero
2024-10-14 15:15:42 +02:00
committed by GitHub
parent 3d97f02a8d
commit 873851b54e
16 changed files with 230 additions and 97 deletions

View File

@@ -6,12 +6,17 @@ interface ErrorReporter {
}
const instance: ErrorReporter = {
report: (error) => {
report: (error, options) => {
if (error instanceof Error) {
let e = error;
const { executionId } = options ?? {};
const context = executionId ? ` (execution ${executionId})` : '';
do {
const msg = [e.message + context, e.stack ? `\n${e.stack}\n` : ''].join('');
const meta = e instanceof ApplicationError ? e.extra : undefined;
Logger.error(`${e.constructor.name}: ${e.message}`, meta);
Logger.error(msg, meta);
e = e.cause as Error;
} while (e);
}

View File

@@ -5,6 +5,7 @@ export type Level = 'warning' | 'error' | 'fatal' | 'info';
export type ReportingOptions = {
level?: Level;
executionId?: string;
} & Pick<Event, 'tags' | 'extra'>;
export class ApplicationError extends Error {