App Insights:禁用SQL依赖遥测 [英] App Insights: Disable SQL Dependency telemetry

查看:83
本文介绍了App Insights:禁用SQL依赖遥测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Azure Application Insights用于网站(Azure App Service). 基于此,我正在使用群集的Umbraco安装程序和hangfire.这两个人每时每刻都在访问数据库,并淹没了我的"App Insights".

I'm using Azure Application Insights for a website (Azure App Service). On that I'm using a clustered Umbraco setup and hangfire. These two alone keep hitting the database every minute and are flooding my 'App Insights'.

所以我的问题是,如何禁用Sql Dependency Tracker? 我查看了ApplicationInsights.config,找不到任何明显的内容. 我可以看到Microsoft.ApplicationInsights.DependencyCollector可能是原因,但我不想删除所有类型的依赖遥测,仅 sql.

So my question is, how do I disable the Sql Dependency Tracker? I've had a look at the ApplicationInsights.config and couldn't find anything obvious. I can see Microsoft.ApplicationInsights.DependencyCollector which is probably responsible, but I don't want to remove all types of dependency telemetry, only sql.

谢谢

推荐答案

您最好的选择是使用遥测处理器过滤掉某些类型的依赖项请求.在下面查看这些资源以获取信息.

Your best bet here is to use a Telemetry Processor to filter out certain types of dependency requests. Check out these resources below for information.

采样,过滤和预处理Application Insights SDK中的遥测

请求过滤遥测处理器的应用见解

示例处理器可能如下所示.

An example processor might look like this.

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;
    }
}

这篇关于App Insights:禁用SQL依赖遥测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆