The cheapest way to do this is to set the Instrumentation key for all 0. There is no NULL iKey, so it effectively just discards the message.
00000000-0000-0000-0000-000000000000
If you want to use Application_Start(), you can do this using either a directive #DEBUG, or you can use a property System.Diagnostics.Debugger.IsAttached. However, this method is not completely reliable. You can try, but your experience can be consistent.
, TelemetryInitializer, Instrumentation , . , , . , Debug , .
public class CustomeWebRequestTelemetryModule : Microsoft.ApplicationInsights.Extensibility.ITelemetryInitializer
{
public void Initialize(ITelemetry telemetry)
{
if (telemetry != null && System.Diagnostics.Debugger.IsAttached)
{
telemetry.Context.InstrumentationKey = "00000000-0000-0000-0000-000000000000";
}
}
}