6
votes

After enabling Application Insights on my Web project, it runs ok for a couple of requests, but then all requests hang indefinitely. This is running locally using the Visual Studio debugger. Using fiddler I can see that a requests are waiting for a response, which never come. There is no error. Eventually Visual Studio also hangs and I need to kill it.

I'm using Visual Studio 2013 update 4. I did right-click on my web project, and click Add Application Insights Telemetry. Next I removed the Instrumentation Key from the ApplicationInsights.config, since I don't want telemetry for local development. The Instrumentation Key will be set in the Azure App Settings for the live application.

If I revert back without Application Insights, I get no hanging.

Any ideas ? Thanks!

3

3 Answers

1
votes

I was running 2.0.0-rc1 and had this problem. Commenting this line of code within ApplicationInsights.config also fixed the issue.

<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">

Upgrading Application Insights to 2.0.0 also solved the issue for me. Thanks Anastasia & Allen!

3
votes

[EDIT]

The previous fix seemed to work at first, but what really did the trick is to comment out the PerformanceCollectorModule from ApplicationInsights.config.

<TelemetryModules>
    ...
    <!--
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
    -->
    ...
</TelemetryModules>

[Old Answer]

Disabling telemetry if no Instrument Key is provided does fix the issue.

I kind of expected this was done under the hood, but it seems not.

I put this code in global.asax Application_Start method:

if (string.IsNullOrEmpty(WebConfigurationManager.AppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"]))
{
    Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.DisableTelemetry = true;
}
2
votes

I don't want to steal any credit from another answer, but I wanted to elaborate on my comment. I re-installed Visual Studio (long-shot I know) and still had the issue. It seems that when the HTTP modules for AI are loaded into IIS Express things go south quickly, so I had to resort to only loading those modules when running the release configuration.

This means updating your web.config to remove the AI statements, and instead move them to Web.Release.config as transforms so they're loaded when a release configuration is built:

https://stackoverflow.com/a/27923364/571237

Note however that the assemblies have changed since that answer was posted. Here's what I needed to add:

  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
    <httpModules>
      <!-- Enable application insights when running in release mode (it don't work right locally...) -->
      <!-- https://stackoverflow.com/a/27923364/571237 -->
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
           xdt:Transform="Insert"/>
    </httpModules>
  </system.web>

  <system.webServer>
    <modules>
      <!-- Enable application insights when running in release mode (it don't work right locally...) -->
      <!-- https://stackoverflow.com/a/27923364/571237 -->
      <remove name="ApplicationInsightsWebTracking" xdt:Transform="Insert"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" xdt:Transform="Insert" />
    </modules>
  </system.webServer>