Application Insights logs handled exceptions (using Polly)
Repro steps
The problem occurs while using Polly library, when using Policy.Handle<HttpRequestException>().RetryAsync() (inside Azure Function). When the exception happens it is logged by application insights although in my opinion it should be regarded as handled
Expected behavior
No exception should be logged
Actual behavior
Exception is logged and is visible request timeline in application insights
Related information
- Azure functions v3
- Link to Polly library: https://github.com/App-vNext/Polly
Any thoughts would be much appreciated
Any news on that?
I have also just hit this issue and am wondering why it's happening
I'm having the same problem, the Polly is handling the exception but the exception is still being logged in Application Insights, any ideas on how to solve this?
I'm running into the same thing.
There is apparently a way to filter out what gets written to app insights; you can write a custom TelemetryProcessor which can check the type of exception before deciding to proceed with logging it or not, but that's not ideal.
I don't want to filter on specific types; I want to filter on whether I'm already handling it with Polly. E.g. if I'm handling SomeException using Policy.Handle in Function A, SomeException shouldn't make it into app insights, but if Function B doesn't handle SomeException then in those cases SomeException should make it into App Insights.
Has anyone come across a better solution? Ultimately I think Polly will need updating.
Morning. Same issue here. It creates a lot of unnecessary noise in Insights, so it would be really nice indeed to get a solution for this.
Cheers.
We thought we had the same issue, but the exceptions that triggers a retry is logged with a severity level of 2, so can be filtered out on that.