Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Make Module configuration easy #634

Closed
cijothomas opened this issue Apr 7, 2018 · 1 comment
Closed

Make Module configuration easy #634

cijothomas opened this issue Apr 7, 2018 · 1 comment
Assignees
Milestone

Comments

@cijothomas
Copy link
Contributor

Provide an ability to configure any TelemetryModule in an easy way as opposed to the following documented way.

Configuring Telemetry Module Services
Inorder to configure any properties of TelemetyModules, obtain the module from DI Container first. Then modify the required properties, and re-initialize the module with currently active Telemetry Configuration.

For eg:, to modify DependencyTrackingTelemetryModule to disable setting Correlationheaders, the following code is required in the Configure method of you Startup class.

DependencyTrackingTelemetryModule dep;
var modules = app.ApplicationServices.GetServices();
foreach(var module in modules)
{
if (module is DependencyTrackingTelemetryModule)
{
dep = module as DependencyTrackingTelemetryModule;
dep.SetComponentCorrelationHttpHeaders = false;
dep.Initialize(TelemetryConfiguration.Active);
}
}

@cijothomas cijothomas added this to the 2.3.0 milestone Apr 7, 2018
@cijothomas cijothomas self-assigned this Apr 7, 2018
@cijothomas cijothomas modified the milestones: 2.3.0, 2.3.0-beta1 Apr 10, 2018
@cijothomas
Copy link
Contributor Author

Addressed via https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/632/files

To configure a telemetry module, use the extension method ConfigureTelemetryModule<T>(Action <T> configModule) on IServiceCollection. This should be done in the ConfigureServices() method of Application's Startup.cs class.

For example, the following shows how to configure DependencyTrackingTelemetryModule

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddApplicationInsightsTelemetry();
            services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module) => {                    
dep.SetComponentCorrelationHttpHeaders = false;
                });
        }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant