Observability: App Insights marks 4xx as successful requests #865
priyaananthasankar
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
According to Data model for request telemetry - Azure Application Insights - Azure Monitor | Microsoft Docs, "For the web applications, Application Insights define a request as successful when the response code is less than 400 or equal to 401." This allows to use Application Insights features to easily detect analyze failing requests.
When using Azure Functions (Python) every request is successful independent on the status code (unless an exception is raised and not handled in the code - this results in a HTTP 500 failing request). This is contradicting to the document the AppInsights data model for request telemetry. Also the current implementation makes it harder to detect and troubleshoot failing requests (as the user has to manually add another filter on the performance tab or work with Kusto queries on the log store)
The only way to overcome that is to raise an exception in the function code (and not catch it). However, this always results in a HTTP 500. Expectation is that a request is marked as unsuccessful for HTTP response with e.g. status code 403/404, etc.
As a consequence, the developer is writing function code which returns a right Http status code for that situation, but as it doesn’t show up in App Insights, the developer has to explicitly raise an exception and make it a 500. Here is the snapshot that shows only 500’s as Failures. This is also not consistent with app insights telemetry model.
This is not consistent with ASP NET documentation here as well – you can see it shows 404: https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-exceptions
This is the same with .NET functions as well but this is not consistent with non-functions based apps. Want to understand if this was an intentional design choice and discuss the pros/cons of this here.
Beta Was this translation helpful? Give feedback.
All reactions