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

Exception logging for MessageReceiver background exceptions #1704

Merged
merged 1 commit into from
May 17, 2018

Conversation

mathewc
Copy link
Member

@mathewc mathewc commented May 17, 2018

Addresses #1703

I'll be making similar changes in v2

@mathewc mathewc requested a review from brettsam May 17, 2018 00:51
@mathewc mathewc force-pushed the mathewc-work-v2.x branch from 8cdcf08 to b9e54ef Compare May 17, 2018 00:53
int deliveryCount,
ILogger log)
{
log.LogInformation($"Processing ServiceBus message (Id={messageId}, DeliveryCount={deliveryCount})");
Copy link
Member Author

Choose a reason for hiding this comment

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

I used this sample function to repro the issue. Before my changes, if I introduced a 7 minute delay in this function, the lock would be lost and I'd get retries without any error messages. With my changes the MessageLockLostException from SB is logged to console.

{
if (!e.Exception.IsWrappedExceptionTransient())
{
context.Trace.Error($"MessageReceiver error (Action={e.Action})", e.Exception);
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm assuming that the TraceWriter is all wired up to AppInsights if AI is enabled @brettsam ?

Copy link
Member

Choose a reason for hiding this comment

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

In v2.x, you need to do the ugly double-logging to both TraceWriter and ILogger. In dev it's just ILogger

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to conditionally log to ILogger as well :)

Copy link
Member

@brettsam brettsam left a comment

Choose a reason for hiding this comment

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

Make sure to log to ILogger in the place mentioned. Other than that, looks good.

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.

2 participants