microsoft / ApplicationInsights-aspnetcore

ASP.NET Core web applications monitoring
313 stars 123 forks source link

Provide disable/enable flag in ApplicationInsightsServiceOptions for each TelemetryModule present in default list. #988

Closed cijothomas closed 5 years ago

cijothomas commented 5 years ago

This will make it easy to remove any default telemetry modules.

The current way to remove a module is: var performanceCounterService = services.FirstOrDefault(t => t.ImplementationType == typeof(PerformanceCollectorModule)); if (performanceCounterService != null) { services.Remove(performanceCounterService); }

Proposed way to remove, for example, DependencyCollection would be:

   var aiOptions  = new ApplicationInsightsServiceOptions();
    // Disables adaptive sampling.
    aiOptions.EnableDependencyCollection = false;
    services.AddApplicationInsightsTelemetry(aiOptions);

There are around 7 modules present by default, and hence there should be 7 new fields with all modules enabled by default.