Azure 应用程序见解从分析中排除第三方库



我们有应用程序见解来分析和衡量我们的应用程序,但它在第三方库中注册异常,给分析带来噪音,所以我想告诉应用程序见解要从分析中排除哪些程序集。

我已经检查了ApplicationInsights.config文档,但没有看到与此相关的任何内容。

那么,是否可以从分析中排除dll?

对于这些类型的过滤器,您可以使用TelemetryProcessor.请参阅文档:

若要筛选遥测数据,请编写遥测处理器并将其注册到 SDK。所有遥测都通过处理器,你可以选择将其从流中删除,或添加属性。这包括来自标准模块(如 HTTP 请求收集器和依赖项收集器(的遥测数据,以及你自己编写的遥测数据。

你可以这样写:

public class ExceptionFilter : ITelemetryProcessor
{
private ITelemetryProcessor next { get; set; }
public ExceptionFilter(ITelemetryProcessor next)
{
this.next = next;
}
public void Process(ITelemetry item)
{
var exceptionTelemetry = item as ExceptionTelemetry;
if(exceptionTelemetry == null || 
!exceptionTelemetry.Exception.StackTrace.Contains("NameOfThirdPartyApp"))
next.Process(item);
}
}

我把它留给你的想象力,识别这些第三方应用程序例外的最佳方法是什么。

最新更新