Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASP.NET integration captures HttpException with 404 status code #718

Closed
kendallb opened this issue May 5, 2020 · 3 comments · Fixed by #719
Closed

ASP.NET integration captures HttpException with 404 status code #718

kendallb opened this issue May 5, 2020 · 3 comments · Fixed by #719
Labels
area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) type:bug
Milestone

Comments

@kendallb
Copy link
Contributor

kendallb commented May 5, 2020

Describe the bug
It is quite common in ASP.NET code to throw an HttpException(404, "Not Found") when buried deep in code when you decide a page should not exist, which then gets handled by the system wide 404 handler. However with DataDog, since the ASP.NET exception handler always logs all exceptions, those all end up in our traces which is quite annoying.

To Reproduce
Just add

    throw new HttpException(404, "Not Found");

anywhere in a controller, and you will notice it gets logged in the traces. Makes the trace look like it errored out, but a 404 is NOT an error.

Expected behavior
404 errors should be ignored

@kendallb
Copy link
Contributor Author

kendallb commented May 5, 2020

I would write my own HttpModule integration to avoid this, but alas it was decided to bundle that with the core DataDog tracer library now, so I get it all no matter what. I could change the implementation and use my own custom library, but I would rather this gets fixed upstream.

My suggestion would be to simply ignore 404 exceptions in the OnError handler for the HttpModule.

@lucaspimentel lucaspimentel changed the title ASP.NET integration captures *all* exceptions and logs to DataDog ASP.NET integration captures HttpException with 404 status code May 11, 2020
@lucaspimentel lucaspimentel linked a pull request May 15, 2020 that will close this issue
@lucaspimentel lucaspimentel added this to the 1.17.0 milestone May 15, 2020
@lucaspimentel
Copy link
Member

@kendallb: your fix for this issue was included in release 1.17.0. Thanks!

@kendallb
Copy link
Contributor Author

Hmm, we are using 1.17 (about to upgrade to the latest now), and I am still seeing this? Might need to debug this again as I am not sure why we are still getting 404's logged. Got any ideas and where these are coming from?

We have a global, custom error handler in our code to catch the 404 and then render the appropriate page, like this one:

https://www.nashbar.com/answer-mini-crank-black-ck-ack15m-p/p1157261?v=1153012

image

@lucaspimentel lucaspimentel added area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) and removed area:integrations/aspnet labels Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) type:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants