Skip to content

Instantly share code, notes, and snippets.

@debugthings
Created July 17, 2017 01:20
Show Gist options
  • Select an option

  • Save debugthings/b082670dac4f468a5aa04abd9dd6c367 to your computer and use it in GitHub Desktop.

Select an option

Save debugthings/b082670dac4f468a5aa04abd9dd6c367 to your computer and use it in GitHub Desktop.
Filter out request telemetry that is not to my hostname
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
using System;
public class NotMyHostNameFilter : Microsoft.ApplicationInsights.Extensibility.ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
private bool parsed = false;
public string ExceptionToFilter { get; set; }
public NotMyHostNameFilter(ITelemetryProcessor next)
{
this.Next = next;
}
public void Process(ITelemetry item)
{
if (item is Microsoft.ApplicationInsights.DataContracts.RequestTelemetry)
{
var request = item as Microsoft.ApplicationInsights.DataContracts.RequestTelemetry;
if (!request.Url.Host.Equals("www.debugthings.com", StringComparison.CurrentCultureIgnoreCase))
{
// If this is not for my server www.debugthings.com then return
return;
}
}
this.Next.Process(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment