Skip to content

Commit bb45914

Browse files
committed
added time reset logics
1 parent c0f8ae0 commit bb45914

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

packages/core/src/Providers/AWSCloudWatchProvider.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class AWSCloudWatchProvider implements LoggingProvider {
5858
private _maxRetries = 5;
5959
private _retryCount;
6060
private _lastAttemptTime: number = 0;
61-
private _resetInterval: number = 5 * 60 * 1000; // 5 minutes
61+
private _resetInterval: number = 1 * 60 * 1000; // 1 minutes
6262

6363
constructor(config?: AWSCloudWatchProviderOptions) {
6464
this.configure(config);
@@ -497,24 +497,23 @@ class AWSCloudWatchProvider implements LoggingProvider {
497497
this._timer = setInterval(async () => {
498498
const now = Date.now();
499499

500-
// Reset retry count if enough time has passed since last attempt
500+
// Time-based reset
501501
if (now - this._lastAttemptTime > this._resetInterval) {
502502
this._retryCount = 0;
503503
}
504504

505505
this._lastAttemptTime = now;
506506

507-
if (!this._getDocUploadPermissibility()) {
508-
return; // Skip this iteration if upload is not permissible
509-
}
510507
try {
511-
await this._safeUploadLogEvents();
512-
if (this._retryCount > 0) {
513-
logger.info(
514-
'CloudWatch log upload succeeded after previous failures.'
515-
);
508+
if (this._getDocUploadPermissibility()) {
509+
await this._safeUploadLogEvents();
510+
this._retryCount = 0; // Reset on success
511+
if (this._retryCount > 0) {
512+
logger.info(
513+
'CloudWatch log upload succeeded after previous failures.'
514+
);
515+
}
516516
}
517-
this._retryCount = 0; // Reset on success
518517
} catch (err) {
519518
this._retryCount++;
520519
if (this._retryCount <= this._maxRetries) {
@@ -524,11 +523,11 @@ class AWSCloudWatchProvider implements LoggingProvider {
524523

525524
if (this._retryCount === this._maxRetries) {
526525
logger.error(
527-
`CloudWatch log upload failed after ${this._maxRetries} attempts. Suppressing further error logs. Upload attempts will continue in the background.`
526+
`Max retries (${this._maxRetries}) reached. Suppressing further error logs. Upload attempts will continue in the background.`
528527
);
529528
}
530529
}
531-
// After max retries, we're still attempting uploads but not logging errors
530+
// Silently continue attempts after max retries
532531
}
533532
}, 2000);
534533
}

0 commit comments

Comments
 (0)