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) {