Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable System.Runtime default counters #2013

Merged
merged 4 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Update AppInsights JS snippet used in the code to [latest version](https://github.com/microsoft/ApplicationInsights-JS)
- [ServerTelemetryChannel does not fall back to any default directory if user explicitly configures StorageFolder, and have trouble read/write to it](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2002)
- [Fixed a bug which caused ApplicationInsights.config file being read for populating TelemetryConfiguration in .NET Core projects](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1795)
- [Remove System.RunTime EventCounters by default](https://github.com/microsoft/ApplicationInsights-dotnet/issues/2009)

## Version 2.15.0-beta2
- [Read all properties of ApplicationInsightsServiceOptions from IConfiguration](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1882)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ public static IServiceCollection AddApplicationInsightsTelemetry(this IServiceCo
AddCommonTelemetryModules(services);
AddTelemetryChannel(services);

#if NETSTANDARD2_0
ConfigureEventCounterModuleWithSystemCounters(services);
#endif

services.TryAddSingleton<IConfigureOptions<ApplicationInsightsServiceOptions>,
DefaultApplicationInsightsServiceConfigureOptions>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ public static IServiceCollection AddApplicationInsightsTelemetryWorkerService(th
AddCommonTelemetryModules(services);
AddTelemetryChannel(services);

ConfigureEventCounterModuleWithSystemCounters(services);
cijothomas marked this conversation as resolved.
Show resolved Hide resolved

services
.TryAddSingleton<IConfigureOptions<ApplicationInsightsServiceOptions>,
DefaultApplicationInsightsServiceConfigureOptions>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,14 +657,9 @@ public static void RegistersTelemetryConfigurationFactoryMethodThatPopulatesEven
var telemetryConfiguration = serviceProvider.GetTelemetryConfiguration();
var eventCounterModule = modules.OfType<EventCounterCollectionModule>().Single();

//VALIDATE
Assert.Equal(19, eventCounterModule.Counters.Count);

// sanity check with a sample counter.
var cpuCounterRequest = eventCounterModule.Counters.FirstOrDefault<EventCounterCollectionRequest>(
eventCounterCollectionRequest => eventCounterCollectionRequest.EventSourceName == "System.Runtime"
&& eventCounterCollectionRequest.EventCounterName == "cpu-usage");
Assert.NotNull(cpuCounterRequest);
// VALIDATE
// By default, no counters are collected.
Assert.Equal(0, eventCounterModule.Counters.Count);
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,29 +393,19 @@ public void VerifyAddAIWorkerServiceSetsUpDefaultConfigurationAndModules()
[Fact]
public static void RegistersTelemetryConfigurationFactoryMethodThatPopulatesEventCounterCollectorWithDefaultListOfCounters()
{
//ARRANGE
// ARRANGE
var services = new ServiceCollection();
services.AddApplicationInsightsTelemetryWorkerService();

//ACT
// ACT
IServiceProvider serviceProvider = services.BuildServiceProvider();
var modules = serviceProvider.GetServices<ITelemetryModule>();
var telemetryConfiguration = serviceProvider.GetRequiredService<TelemetryConfiguration>();
var eventCounterModule = modules.OfType<EventCounterCollectionModule>().Single();

//VALIDATE
Assert.Equal(19, eventCounterModule.Counters.Count);

// sanity check with a sample counter.
var cpuCounterRequest = eventCounterModule.Counters.FirstOrDefault<EventCounterCollectionRequest>(
eventCounterCollectionRequest => eventCounterCollectionRequest.EventSourceName == "System.Runtime"
&& eventCounterCollectionRequest.EventCounterName == "cpu-usage");
Assert.NotNull(cpuCounterRequest);

// sanity check - no asp.net counters should be added
var aspnetCounterRequest = eventCounterModule.Counters.FirstOrDefault<EventCounterCollectionRequest>(
eventCounterCollectionRequest => eventCounterCollectionRequest.EventSourceName == "Microsoft.AspNetCore.Hosting");
Assert.Null(aspnetCounterRequest);
// VALIDATE
// By default, no counters are collected.
Assert.Equal(0, eventCounterModule.Counters.Count);
}

[Fact]
Expand Down