Skip to content

Commit ebb2cfb

Browse files
committed
set log output limits to 5
1 parent 774c242 commit ebb2cfb

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packages/core/src/Providers/AWSCloudWatchProvider.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class AWSCloudWatchProvider implements LoggingProvider {
5555
private _currentLogBatch: InputLogEvent[];
5656
private _timer;
5757
private _nextSequenceToken: string | undefined;
58+
private _maxRetries = 5;
59+
private _retryCount;
5860

5961
constructor(config?: AWSCloudWatchProviderOptions) {
6062
this.configure(config);
@@ -494,11 +496,22 @@ class AWSCloudWatchProvider implements LoggingProvider {
494496
try {
495497
if (this._getDocUploadPermissibility()) {
496498
await this._safeUploadLogEvents();
499+
this._retryCount = 0;
497500
}
498501
} catch (err) {
499-
logger.error(
500-
`error when calling _safeUploadLogEvents in the timer interval - ${err}`
501-
);
502+
this._retryCount++;
503+
if (this._retryCount < this._maxRetries) {
504+
logger.error(
505+
`error when calling _safeUploadLogEvents in the timer interval - ${err}`
506+
);
507+
logger.error(
508+
`Max retries (${this._maxRetries}) reached. Stopping log uploads.`
509+
);
510+
} else if (this._retryCount == this._maxRetries) {
511+
logger.error(
512+
`Max retries (${this._maxRetries}) reached. Stopping log uploads.`
513+
);
514+
}
502515
}
503516
}, 2000);
504517
}

0 commit comments

Comments
 (0)