如何忽略Azure应用程序见解中的本地主机 [英] How to Ignore localhost on Azure application insights
问题描述
我最近开始托管我的第一个生产应用程序.我继续并激活了应用程序见解,我认为这些见解具有很大的价值.但是,我得到了来自开发人员方面的统计信息,例如日志正在记录来自localhost:xxxx的条目.我确定有办法将其关闭.有人可以给我一些指示吗?
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?
推荐答案
您还可以使用TelemetryProcessor过滤localhost遥测(如果使用的是最新的(Application Insights Web SDK的预发行版本).您的项目:
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);
}
}
}
然后在ApplicationInsights.config中注册它:
And then register it in ApplicationInsights.config:
<TelemetryProcessors>
<Add Type="LocalhostFilterSample.LocalHostTelemetryFilter, LocalHostFilterSample"/>
</TelemetryProcessors>
这篇关于如何忽略Azure应用程序见解中的本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!