如何在Azure应用程序洞察中忽略localhost

我最近开始主持我的第一个生产应用程序 我继续并激活应用程序见解,我认为这些有很多价值。 但是,我得到了来自开发人员方面的统计信息,例如日志记录来自localhost:xxxx的条目。 我确定有办法解决这个问题。 谁能给我一些指示吗?

您还可以使用TelemetryProcessor过滤localhost遥测(如果您使用的是最新版本(Application Insights Web SDK的预发布版本)。这是一个示例。将此类添加到您的项目中:

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中注册它:

    
  1. 您可以过滤掉在UI中使用F5获得的已收集遥测数据,因为它具有属性IsDeveloperMode = true
  2. 您可以进行web.config转换,从web.debug.config中删除Application Insights模块,并将其保留在web.release.config中(如果您只有自动收集的属性)
  3. 您可以从配置中删除检测密钥,并仅将其设置为代码中的发布版本:TelemetryConfiguration.Active.InsrumentationKey =“MyKey”(如果您未在调试中提供iKey,您仍可以在VS 2015中查看AI集线器中的所有遥测)
  4. 您可以使用不同的iKeys进行调试,并通过在代码中进行设置再次发布
  5. 您可以通过设置TelemetryConfiguration.Active.DisableTelemetry = true在调试中完全禁用ApplicationInsights