Azure / azure-webjobs-sdk

Azure WebJobs SDK
MIT License
737 stars 358 forks source link

Application Insights logs handled exceptions (using Polly) #2612

Open piotrzbyszynski opened 3 years ago

piotrzbyszynski commented 3 years ago

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

Any thoughts would be much appreciated

piotrzbyszynski commented 3 years ago

Any news on that?

george-ayris commented 3 years ago

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

MatheusXavier commented 1 year ago

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?

Orionsgate commented 1 year ago

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.

josealbertocoronado commented 1 year ago

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.

vincelee888 commented 4 months ago

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.