azure - 应用洞察 : Disable SQL Dependency telemetry

标签 azure azure-sql-database azure-application-insights

我正在将 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/

相关文章:

asp.net-mvc - 从 Azure 中托管的 ASP.NET Core 5.0 MVC 站点调用 API/服务时出现间歇性套接字异常

c# - ILogger 到应用程序洞察

json - Azure Devops - 从一个任务输出 Json 对象并在另一任务中使用

azure - 如何在 Azure HDInsight 中的工作节点上安装自定义软件?

Azure - 无法删除 SQL Server

azure - 使用 Enterprise Library 5 登录到 SQL Azure 可以从开发计算机工作,但不能从 Web 角色工作

asp.net-mvc - 将 MVC 4 CodeFirst 部署到 Azure

c# - UWP 应用程序是否支持 Application Insights?

visual-studio - 使用 Azure Functions 进行应用程序洞察搜索

azure - azure 持久功能是否是 azure 服务总线的合适替代方案?