From 0d1a1d333b8d640ff3e3a460385d23a3034f31fb Mon Sep 17 00:00:00 2001 From: Hector Hernandez <39923391+hectorhdzg@users.noreply.github.com> Date: Thu, 14 Dec 2023 13:00:51 -0800 Subject: [PATCH] Update --- .../src/export/BatchLogRecordProcessorBase.ts | 8 ++------ .../sdk-logs/src/export/SimpleLogRecordProcessor.ts | 13 +++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/experimental/packages/sdk-logs/src/export/BatchLogRecordProcessorBase.ts b/experimental/packages/sdk-logs/src/export/BatchLogRecordProcessorBase.ts index 6b59152399..bfe6367cf2 100644 --- a/experimental/packages/sdk-logs/src/export/BatchLogRecordProcessorBase.ts +++ b/experimental/packages/sdk-logs/src/export/BatchLogRecordProcessorBase.ts @@ -178,9 +178,7 @@ export abstract class BatchLogRecordProcessorBase ); } }) - .catch(error => { - globalErrorHandler(error); - }); + .catch(globalErrorHandler); const pendingResources = logRecords .map(logRecord => logRecord.resource) @@ -192,9 +190,7 @@ export abstract class BatchLogRecordProcessorBase } else { return Promise.all( pendingResources.map(resource => resource.waitForAsyncAttributes?.()) - ).then(doExport, err => { - globalErrorHandler(err); - }); + ).then(doExport, globalErrorHandler); } } diff --git a/experimental/packages/sdk-logs/src/export/SimpleLogRecordProcessor.ts b/experimental/packages/sdk-logs/src/export/SimpleLogRecordProcessor.ts index b3da9df4df..97134c886b 100644 --- a/experimental/packages/sdk-logs/src/export/SimpleLogRecordProcessor.ts +++ b/experimental/packages/sdk-logs/src/export/SimpleLogRecordProcessor.ts @@ -52,22 +52,19 @@ export class SimpleLogRecordProcessor implements LogRecordProcessor { ); } }) - .catch(error => { - globalErrorHandler(error); - }); + .catch(globalErrorHandler); // Avoid scheduling a promise to make the behavior more predictable and easier to test if (logRecord.resource.asyncAttributesPending) { - const exportPromise = logRecord.resource.waitForAsyncAttributes?.().then( - () => { + const exportPromise = logRecord.resource + .waitForAsyncAttributes?.() + .then(() => { // Using TS Non-null assertion operator because exportPromise could not be null in here // if waitForAsyncAttributes is not present this code will never be reached // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this._unresolvedExports.delete(exportPromise!); return doExport(); - }, - err => globalErrorHandler(err) - ); + }, globalErrorHandler); // store the unresolved exports if (exportPromise != null) {