Skip to content

Commit

Permalink
Ignore 404 exceptions (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
kendallb authored May 15, 2020
1 parent b864eec commit 4fb4e40
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Datadog.Trace.AspNet/TracingHttpModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,15 @@ private void OnError(object sender, EventArgs eventArgs)
try
{
var httpContext = (sender as HttpApplication)?.Context;
var exception = httpContext?.Error;

if (httpContext?.Error != null &&
httpContext.Items[_httpContextScopeKey] is Scope scope)
// We want to ignore 404 exceptions here, as they are not errors
var httpException = exception as HttpException;
var is404 = httpException?.GetHttpCode() == 404;

if (exception != null && !is404 && httpContext.Items[_httpContextScopeKey] is Scope scope)
{
scope.Span.SetException(httpContext.Error);
scope.Span.SetException(exception);
}
}
catch (Exception ex)
Expand Down

0 comments on commit 4fb4e40

Please sign in to comment.