azure - 应用程序洞察 : How to disable SQL Dependency telemetry

标签 azure azure-application-insights

我们将 Azure Application Insights 用于网站(Azure 应用服务),并且 SQL 依赖项日志正在填满日志。 Transaction logs

我们已在 ApplicationInsights.config 中注释了以下行
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"/>

我们可以在哪里禁用这些?

最佳答案

我在 SO 中发现了类似的问题,涉及禁用 SQL 依赖项遥测(Application Insights),其中 James Davis 提供了解决方案](App Insights: Disable SQL Dependency telemetry)“https://stackoverflow.com/q/38320886/16630138) ") 这可能有助于满足您的要求

using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.DataContracts;

public class SuccessfulDependencyFilter : ITelemetryProcessor
{
    private ITelemetryProcessor Next { get; set; }

    // next will point to the next TelemetryProcessor in the chain.
    public SuccessfulDependencyFilter(ITelemetryProcessor next)
    {
        this.Next = next;
    }

    public void Process(ITelemetry item)
    {
        // To filter out an item, return without calling the next processor.
        if (!OKtoSend(item)) { return; }

        this.Next.Process(item);
    }

    // Example: replace with your own criteria.
    private bool OKtoSend (ITelemetry item)
    {
        var dependency = item as DependencyTelemetry;
        if (dependency == null) return true;

        return dependency.Success != true;
    }
}

引用link

关于azure - 应用程序洞察 : How to disable SQL Dependency telemetry,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74602263/

相关文章:

azure - Azure Batch 虚拟机是否会在作业完成后自动关闭?

node.js - 用于项目和部署特定变量的 Azure DevOps 管道

c# - 我们可以使用应用程序洞察来进行集中日志记录吗?

azure - Azure Application Insights 中的 session 持续时间

.net - Application Insights SDK SQL 依赖项跟踪不适用于 Microsoft.Data.SqlClient 2.0

azure-application-insights - 应用洞察 : Script error at unknown

sql-server - 与 Entity Framework 和 transient 故障处理 block 的连接?

azure - 强化 Azure Web Apps 和 Azure SQL 数据库之间的安全性

.NET CosmosDB NoSQL 查询来匹配对象模型

azure - 如何在 Azure Web 应用程序中创建包含两个日期/时间之间的每个 URL 命中的报告?