public static void RegistersTelemetryConfigurationFactoryMethodThatReadsEndpointAddressFromEnvironment() { var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); Environment.SetEnvironmentVariable("APPINSIGHTS_ENDPOINTADDRESS", "http://localhost:1234/v2/track/"); var config = new ConfigurationBuilder().AddEnvironmentVariables().Build(); try { services.AddApplicationInsightsTelemetry(config); IServiceProvider serviceProvider = services.BuildServiceProvider(); var telemetryConfiguration = serviceProvider.GetRequiredService <TelemetryConfiguration>(); Assert.Equal("http://localhost:1234/v2/track/", telemetryConfiguration.TelemetryChannel.EndpointAddress); } finally { Environment.SetEnvironmentVariable("APPINSIGHTS_ENDPOINTADDRESS", null); } }
public static void RegistersTelemetryConfigurationFactoryMethodThatReadsInstrumentationKeyFromEnvironment() { var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); Environment.SetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY", "11111111-2222-3333-4444-555555555555"); var config = new ConfigurationBuilder().AddEnvironmentVariables().Build(); try { services.AddApplicationInsightsTelemetry(config); IServiceProvider serviceProvider = services.BuildServiceProvider(); var telemetryConfiguration = serviceProvider.GetRequiredService <TelemetryConfiguration>(); Assert.Equal("11111111-2222-3333-4444-555555555555", telemetryConfiguration.InstrumentationKey); } finally { Environment.SetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY", null); } }
public static void RegistersTelemetryConfigurationFactoryMethodThatReadsDeveloperModeFromEnvironment() { var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); Environment.SetEnvironmentVariable("APPINSIGHTS_DEVELOPER_MODE", "true"); var config = new ConfigurationBuilder().AddEnvironmentVariables().Build(); try { services.AddApplicationInsightsTelemetry(config); IServiceProvider serviceProvider = services.BuildServiceProvider(); var telemetryConfiguration = serviceProvider.GetRequiredService <TelemetryConfiguration>(); Assert.Equal(true, telemetryConfiguration.TelemetryChannel.DeveloperMode); } finally { Environment.SetEnvironmentVariable("APPINSIGHTS_DEVELOPER_MODE", null); } }
public static void RegistersTelemetryConfigurationFactoryMethodThatPopulatesItWithModulesFromContainer() { var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor(); services.AddApplicationInsightsTelemetry(new ConfigurationBuilder().Build()); IServiceProvider serviceProvider = services.BuildServiceProvider(); var modules = serviceProvider.GetServices <ITelemetryModule>(); Assert.NotNull(modules); Assert.Equal(2, modules.Count()); var dependencyModule = services.FirstOrDefault <ServiceDescriptor>(t => t.ImplementationType == typeof(DependencyTrackingTelemetryModule)); Assert.NotNull(dependencyModule); var perfCounterModule = services.FirstOrDefault <ServiceDescriptor>(t => t.ImplementationType == typeof(PerformanceCollectorModule)); Assert.NotNull(perfCounterModule); }