6

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?

Leo
  • 5,013
  • 1
  • 28
  • 65
SteppingRazor
  • 1,222
  • 1
  • 9
  • 25

1 Answers1

6

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

Leo
  • 5,013
  • 1
  • 28
  • 65