Turn off Application Insights for non-release debug build configurations

Use the build configurations, Web.config transforms, and the Debug constant to enable statistics for the release mode only
Move the Instrumentation Key from the Application Insights config file to the web.config file
First remove the Instrumentation Key from the Application Insights config file.

Next, add an <appSetting> to the main Web.config and set it's value to an empty string.

Then in the Web.Release.config transform file, set the value to the account's instrumentation key.
Note: Did you know you can right click the Web.Release.config and select "Preview Transform" to see the change?

Finally, in the Global.asax.cs, set the InstrumentationKey in code.
 
Web.config:
  <appSetting>
    <add key="iKey" value="" />

Web.Release.Config:
  <add key="actual key value" xdd:Transform="SetAttributes" xdd:Locator="Match(key)" />

Global.asax.cs:
  Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey =
    WebConfigurationManager.AppSettings["iKey"];
 
Change Razor views to use key from code
The razor layouts and views may have the instrumentation key hardcoded. Change these to use the key set in Global.asax.cs.

Find the hardcoded key in the razor files and change them to the following:
 
instrumentationKey:
"@Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey"
 
Disable telemetry calls in debug mode
In the Startup class, create a new method with the conditional debug attribute and call it from the Configuration() method.

Then in your project Properties, Build tab, check the "Define DEBUG constant" for your non-release mode configurations.
 
[Conditional("DEBUG")]
private static void DisableApplicationInsightsOnDebug()
{
  TelemetryConfiguration.Active.DisableTelemetry = true;
}
 

For further information, see the following:

Separating telemetry from Development, Test, and Production