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

Change log level of retry simple attempt #86

Closed

Conversation

sergiosimoes025
Copy link

@sergiosimoes025 sergiosimoes025 commented May 3, 2022

Description

The log level of attempts of the simple retry definition is Error. Since this is a retry attempt, the log level should be Verbose.

This PR changes the log level of the retry attempt to Verbose.

Fixes #85

How Has This Been Tested?

Test the consumption of events locally, and ensure that the log level of the retry attempt is verbose.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have made corresponding changes to the documentation

Disclaimer

By sending us your contributions, you are agreeing that your contribution is made subject to the terms of our Contributor Ownership Statement

andrecoutosilva
andrecoutosilva previously approved these changes May 3, 2022
@@ -51,9 +51,8 @@ public async Task Invoke(IMessageContext context, MiddlewareDelegate next)
}
}

this.logHandler.Error(
this.logHandler.Verbose(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that the log level of a retry attempt in this context should be Verbose, nevertheless, when the message fails the first time, I think the log level should be Error so the users will know that something wrong is happening. What do you think about this? Here is a suggestion:

                       var logMsg = $"Exception captured by {nameof(RetrySimpleMiddleware)}. Retry in process.";

                        var logObj = new
                        {
                            AttemptNumber = attemptNumber,
                            WaitMilliseconds = waitTime.TotalMilliseconds,
                            PartitionNumber = context.ConsumerContext.Partition,
                            Worker = context.ConsumerContext.WorkerId,
                            //Headers = context.HeadersAsJson(),
                            //Message = context.Message.ToJson(),
                            ExceptionType = exception.GetType().FullName,
                            ExceptionMessage = exception.Message
                        };

                        if (attemptNumber == 1)
                        {
                            this.logHandler.Error(logMsg, exception, logObj);
                        }
                        else
                        {
                            this.logHandler.Verbose(logMsg, logObj);
                        }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi ! We are also looking for this feature, but could we log the last attempt instead of the first one? If a message is retried only once and then passes, it means the issue is temporary and we don't have to deal with it, but if after all the retries we still can't consume, then we have a problem that we have to deal.

@fernando-a-marins
Copy link
Contributor

After some conversation with the finance open-source team, we concluded that this PR shouldn't be merged. The users may accomplish this issue using the retry durable and using some metadata that flows in the headers of the messages. In the property IMessageContext.Headers you will find a header with the key "Kafka-Flow-Retry-Durable-Attempts-Count" that will give you the number of attempts, if zero, it means that the message is not in retry. Use that to log as you wish in your applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change log level of the simple retry to verbose
8 participants