azure – App Insights:禁用SQL依赖关系遥测

前端之家收集整理的这篇文章主要介绍了azure – App Insights:禁用SQL依赖关系遥测前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在将Azure Application Insights用于网站(Azure App Service).
在那我正在使用集群Umbraco设置和hangfire.这两个人每分钟都在不断地访问数据库,并且充斥着我的“App Insights”.

所以我的问题是,如何禁用sql Dependency Tracker?
我看过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;
    }
}
原文链接:https://www.f2er.com/mssql/84350.html

猜你在找的MsSQL相关文章