我正在将 Azure Application Insights 用于网站(Azure 应用服务)。 我正在使用集群 Umbraco 设置和 Hangfire。仅这两个人就每分钟都在访问数据库,并且淹没了我的“App Insights”。
所以我的问题是,如何禁用 Sql 依赖跟踪器? 我查看了 ApplicationInsights.config,但找不到任何明显的东西。 我可以看到 Microsoft.ApplicationInsights.DependencyCollector 可能是负责的,但我不想删除所有类型的依赖项遥测,仅 sql。
谢谢
最佳答案
这里最好的选择是使用遥测处理器来过滤掉某些类型的依赖请求。查看下面的这些资源以获取信息。
Sampling, filtering and preprocessing telemetry in the Application Insights SDK
Request filtering in Application Insights with Telemetry Processor
示例处理器可能如下所示。
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.DataContracts;
public class NoSQLDependencies : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
// Link processors to each other in a chain.
public NoSQLDependencies(ITelemetryProcessor next)
{
this.Next = next;
}
public void Process(ITelemetry item)
{
if (IsSQLDependency(item)) { return; }
this.Next.Process(item);
}
private bool IsSQLDependency(ITelemetry item)
{
var dependency = item as DependencyTelemetry;
if (dependency?.DependencyTypeName == "SQL")
{
return true;
}
return false;
}
}
关于azure - 应用洞察 : Disable SQL Dependency telemetry,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38320886/