You can also filter localhost telemetry using the TelemetryProcessor (if you are using the latest (pre-release version of the Application Insights Web SDK). Here is an example. Add this class to your project:
public class LocalHostTelemetryFilter : ITelemetryProcessor { private ITelemetryProcessor next; public LocalHostTelemetryFilter(ITelemetryProcessor next) { this.next = next; } public void Process(ITelemetry item) { var requestTelemetry = item as RequestTelemetry; if (requestTelemetry != null && requestTelemetry.Url.Host.Equals("localhost", StringComparer.OrdinalIgnoreCase)) { return; } else { this.next.Process(item); } } }
And then register it in ApplicationInsights.config:
<TelemetryProcessors> <Add Type="LocalhostFilterSample.LocalHostTelemetryFilter, LocalHostFilterSample"/> </TelemetryProcessors>
source share