Skip to content

Instantly share code, notes, and snippets.

@patkleef
Last active March 13, 2017 19:27
Show Gist options
  • Select an option

  • Save patkleef/ad761348db9783e5789412b7f9a98ac8 to your computer and use it in GitHub Desktop.

Select an option

Save patkleef/ad761348db9783e5789412b7f9a98ac8 to your computer and use it in GitHub Desktop.
Application Insights Blog - ApplicationInsightsNotFoundFilter.cs
public class NotFoundFilter : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
public NotFoundFilter(ITelemetryProcessor next)
{
this.Next = next;
}
public void Process(ITelemetry item)
{
var request = item as RequestTelemetry;
if (request != null &&
request.ResponseCode.Equals(((int)HttpStatusCode.NotFound).ToString(), StringComparison.OrdinalIgnoreCase))
{
// To filter out an item, just terminate the chain:
return;
}
// Send everything else:
this.Next.Process(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment