Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ApplicationInsights TelemetryClient is very slow at initializing when in Debug

I have a problem with Microsoft.ApplicationInsights objects. Every time the code hits one of those objects for the first time, the time to initialize is ridiculously long (sometimes even around 40 seconds).

Example 1:

First initialization of TelemetryClient

Example 2:

DisableTelemtry

What is the cause of this long first time load? How can I fix this?

like image 239
SteppingRazor Avatar asked Feb 16 '18 10:02

SteppingRazor


People also ask

How do I disable Applicationsinsights?

Click on "Microsoft. ApplicationInsights. AspNetCore" package. On the right, check the checkbox next to Project to select all projects then select Uninstall.

How do I delete data from application Insights?

The only way to do that is to delete the entire Application Insights service configuration through the portal. And currently Application Insights has 7 days retention policy, so all data will be deleted automatically in 7 days.

What is the use of ApplicationInsights config?

Collects system performance counters such as CPU, memory, and network load from IIS installations. You can specify which counters to collect, including performance counters you have set up yourself. Microsoft. ApplicationInsights.

How do I log custom events in application Insights?

In the Azure Portal, navigate to the Application Insights resource, and click Log Analytics. Log queries help you to fully leverage the value of the data collected in Azure Monitor Logs. Query your custom events by entering “customEvents” in the prompt and click Run.


1 Answers

Why don't you just disable ApplicationInsight when in debug using a web.config transform?

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.web>
      <httpModules>
        <add xdt:Transform="Remove" xdt:Locator="Match(name)" name="ApplicationInsightsWebTracking" />
      </httpModules>
  </system.web>
  <system.webServer>
    <modules>
      <add xdt:Transform="Remove" xdt:Locator="Match(name)" name="ApplicationInsightsWebTracking"  />
    </modules>
  </system.webServer>
</configuration>

I had similar issues and the answer to this question explained to me how to go about using this snippet in my dev environment (ie. not in the publishing pipeline).

like image 51
Leo Avatar answered Oct 21 '22 15:10

Leo