azure-webjobs-sdk icon indicating copy to clipboard operation
azure-webjobs-sdk copied to clipboard

Application Insights logs handled exceptions (using Polly)

Open piotrzbyszynski opened this issue 5 years ago • 6 comments

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

piotrzbyszynski avatar Oct 23 '20 14:10 piotrzbyszynski

Any news on that?

piotrzbyszynski avatar Apr 28 '21 11:04 piotrzbyszynski

I have also just hit this issue and am wondering why it's happening

george-ayris avatar Sep 06 '21 10:09 george-ayris

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?

MatheusXavier avatar Sep 15 '22 13:09 MatheusXavier

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.

Orionsgate avatar Jun 27 '23 12:06 Orionsgate

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.

josealbertocoronado avatar Aug 04 '23 06:08 josealbertocoronado

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.

vincelee888 avatar May 01 '24 08:05 vincelee888