Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore specific http status codes from errors

I have a web application monitored with Application Insights but in the errors view I see non 500 http status responses being registered as errors. Is there a way to tell insights to only register 500 status codes or ignore 400 status codes from the captured events?

like image 767
evilpilaf Avatar asked Nov 23 '25 07:11

evilpilaf


1 Answers

Yes, there is a way. What you can do is register a custom Telemetry Initializer and do something like this:

 public void Initialize(Microsoft.ApplicationInsights.Channel.ITelemetry telemetry)
 {
            if (telemetry is RequestTelemetry && ((RequestTelemetry)telemetry).ResponseCode == "400")
            {
               ((RequestTelemetry)telemetry).Success = true;
            }
 }
like image 99
Alex Bulankou Avatar answered Nov 24 '25 21:11

Alex Bulankou