Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logging): Fixed AWSCloudWatch output infinite number of errors when access denied #13804

Open
wants to merge 5 commits into
base: v5-stable
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions packages/core/src/Providers/AWSCloudWatchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class AWSCloudWatchProvider implements LoggingProvider {
private _currentLogBatch: InputLogEvent[];
private _timer;
private _nextSequenceToken: string | undefined;
private _maxRetries = 5;
private _retryCount;

constructor(config?: AWSCloudWatchProviderOptions) {
this.configure(config);
Expand Down Expand Up @@ -494,11 +496,19 @@ class AWSCloudWatchProvider implements LoggingProvider {
try {
if (this._getDocUploadPermissibility()) {
await this._safeUploadLogEvents();
this._retryCount = 0;
}
} catch (err) {
logger.error(
`error when calling _safeUploadLogEvents in the timer interval - ${err}`
);
this._retryCount++;
if (this._retryCount < this._maxRetries) {
logger.error(
`error when calling _safeUploadLogEvents in the timer interval - ${err}`
);
} else if (this._retryCount === this._maxRetries) {
yuhengshs marked this conversation as resolved.
Show resolved Hide resolved
logger.error(
`CloudWatch log upload failed after ${this._maxRetries} attempts. Suppressing further error logs. Upload attempts will continue in the background.`
);
}
}
}, 2000);
}
Expand Down
Loading