I started hosting my first production application recently. I went ahead and activated application insights, which I think have a lot of value. However, I'm getting stats which come from the developer side, for example logs are recording entries from localhost:xxxx. I'm sure there is a way to turn this off. Can anyone give me some pointers please?
You can also filter localhost telemetry using TelemetryProcessor (if you are using the latest (prerelease version of Application Insights Web SDK). Here's 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With