Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Insights: Disable SQL Dependency telemetry

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'.

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.

Thanks

like image 970
Sam7 Avatar asked Jul 12 '16 05:07

Sam7


People also ask

How do I disable Insights telemetry app?

To remove Application Insights, you'll need to remove the NuGet packages and references from the API in your application. You can uninstall NuGet packages by using the Package Management Console or Manage NuGet Solution in Visual Studio.

What are dependencies in app Insights?

A dependency is a component that is called by your application. It's typically a service called using HTTP, or a database, or a file system. Application Insights measures the duration of dependency calls, whether it's failing or not, along with additional information like name of dependency and so on.

What is telemetry in application Insights?

Application Insights telemetry model defines a way to correlate telemetry to the operation of which it's a part. For example, a request can make a SQL Database calls and recorded diagnostics info. You can set the correlation context for those telemetry items that tie it back to the request telemetry.

Does application Insights affect performance?

The Application Insights SDK and instrumentation is designed to be extremely lightweight and have minimal impact on the performance of your application.


1 Answers

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.

Sampling, filtering and preprocessing telemetry in the Application Insights SDK

Request filtering in Application Insights with Telemetry Processor

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;
    }
}
like image 68
James Davis - MSFT Avatar answered Sep 27 '22 18:09

James Davis - MSFT