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!
The Application Insights SDK and instrumentation is designed to be extremely lightweight and have minimal impact on the performance of your application.
Application Insights is a feature of Azure Monitor that provides extensible application performance management (APM) and monitoring for live web apps. Developers and DevOps professionals can use Application Insights to: Automatically detect performance anomalies. Help diagnose issues by using powerful analytics tools.
Select File | New Project. Select Visual C# | . NET Core | ASP.NET Core Web Application, ensure to mark the checkbox Add Application Insights to Project. Click Ok on the next screen.
Enabling the application insights on the web app through the portal does this in the back ground for you. App settings need to be updated with some settings that configures your web app to send its telemetry data to Application Insights. Restart the web app.
The basic Application Insights pricing plan has no charge until your app has substantial usage. To use Application Insights at run time, you can instrument your web app on the server. This approach is ideal for apps that are already deployed, because it avoids any updates to the app code.
Enable the Application Insights Extension in Portal and setup the settings. Get the app settings. Use these app settings when configuring your app settings through powerhell. Delete this webapp.
Application Insights will keep it’s configuration in an ApplicationInsights.config file in your web app root folder and some nuget packages in your App_Data folder and additional dlls in the bin folder. The configuration file, dlls and packages can be be lost when you redeploy.
[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;
}
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With