Azure / azure-functions-servicebus-extension

Service Bus extension for Azure Functions
MIT License
65 stars 35 forks source link

Transcient exceptions in Application Insights logs #118

Open Eugenyl opened 3 years ago

Eugenyl commented 3 years ago

Need a way to avoid logging transcient exceptions to MS Application Insights.

Best of all, without any additional configuration. At least need to change category from "Host.Executor" to something more specific to service bus processing so end-user will be able to increase mininum log level for service-bus-specific category without affecting "Host.Executor" category.

Another solution can be a possibility to override function responsible for loggig Azure Service Bus Exceptions so in code it will be possible to sort out transcient exceptions.

Microsoft.Extensions.Hosting, ServiceBusHostBuilderExtensions class, AddServiceBus method. doesn't allow to override. It points to ServiceBusOption class, Exception member handler. The handler is internal, so it's not possible to override. internal Action ExceptionHandler { get; set; } https://github.com/Azure/azure-functions-servicebus-extension/blob/062a555f203b34fc3f0779fc2a85365f643276ae/src/Microsoft.Azure.WebJobs.Extensions.ServiceBus/Config/ServiceBusOptions.cs#L121

Packages/Versions: Microsoft.Azure.WebJobs.Extensions.ServiceBus, v4.1.1 Microsoft.Azure.WebJobs, v3.0.16 Logging assembilies: "Microsoft.Extensions.Logging", "Microsoft.Azure.WebJobs.Logging.ApplicationInsights"

Usage: direct work with WebJobs in C# console application.

There are some samples:

Category: "Host.Executor" Formatted message: "Message processing error (Action=Receive, ClientId=some_client, EntityPath=, Endpoint=somepoint.servicebus.windows.net)"

LogLevel: "Information" Exception type: Microsoft.Azure.ServiceBus.ServiceBusException Message: The connection was inactive for more than the allowed 60000 milliseconds and is closed by container '6c736b9b-b73d-4e26-84b9-04f8b2ec3e8e'.Reference: 6bd88d2308cc44ed83d96d632efc4c56_G3, 10/15/2020 4:56:25 AM The connection was inactive for more than the allowed 60000 milliseconds and is closed by container '6c736b9b-b73d-4e26-84b9-04f8b2ec3e8e'.

LogLevel: "Information" Exception type: "System.OperationCanceledException" Message: The operation was canceled.Reference: 2d16aa02d17148178377ad4db523d63f_G2, 9/17/2020 4:04:59 AM The operation was canceled.

LogLevel: "Error"
Exception type: "Microsoft.Azure.ServiceBus.MessageLockLostException" Message: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue. Reference:c07a6c2c-5d21-4d23-81ba-099d6bb5f2a0, TrackingId:7159312b-7baf-4a72-821b-983c956f8e46_B17, SystemTracker:someserver:queue:somequeue~15, Timestamp:2020-08-30T00:54:36

LogLevel: "Information" Exception type: Microsoft.Azure.ServiceBus.ServiceBusException Message: The link 'e249a97a-a74b-4b65-ba01-8c5036d8bedb;21:26:27:source(address:somequeue):MessageReceiver2some' is force detached. Code: RenewToken. Details: Unauthorized access. 'Listen' claim(s) are required to perform this operation. Resource: 'sb://somecompanyervicebus.servicebus.windows.net/somequeue'.. TrackingId:3d4ce7c144fc4df2a4160c657f6ff1ab_G11, SystemTracker:sometracker, Timestamp:2020-07-26T08:09:33Reference: 3d4ce7c144fc4df2a4160c657f6ff1ab_G11, 7/26/2020 8:09:33 AM The link 'e249a97a-a74b-4b65-ba01-8c5036d8bedb;21:26:27:source(address:somequeue):MessageReceiver2somequeue' is force detached. Code: RenewToken. Details: Unauthorized access. 'Listen' claim(s) are required to perform this operation. Resource: 'sb://somecompanyervicebus.servicebus.windows.net/somequeue'.. TrackingId:3d4ce7c144fc4df2a4160c657f6ff1ab_G11, SystemTracker:sometracker, Timestamp:2020-07-26T08:09:33

github azureservicebus issue