1
0
Форкнуть 0

refactor ApplicationInsightsServiceOptions (#993)

This commit is contained in:
Timothy Mothra 2019-09-25 10:39:55 -07:00 коммит произвёл GitHub
Родитель 1387908e47
Коммит 6ae79f05db
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 38 добавлений и 41 удалений

Просмотреть файл

@ -110,7 +110,7 @@
ApplicationInsightsServiceOptions options)
{
services.AddApplicationInsightsTelemetry();
ConfigureAiServiceOption(services, options);
services.Configure((ApplicationInsightsServiceOptions o) => options.CopyPropertiesTo(o));
return services;
}

Просмотреть файл

@ -86,7 +86,7 @@ namespace Microsoft.Extensions.DependencyInjection
ApplicationInsightsServiceOptions options)
{
services.AddApplicationInsightsTelemetryWorkerService();
ConfigureAiServiceOption(services, options);
services.Configure((ApplicationInsightsServiceOptions o) => options.CopyPropertiesTo(o));
return services;
}

Просмотреть файл

@ -465,44 +465,6 @@
}
#endif
private static void ConfigureAiServiceOption(IServiceCollection services, ApplicationInsightsServiceOptions options)
{
services.Configure((ApplicationInsightsServiceOptions o) =>
{
if (options.DeveloperMode != null)
{
o.DeveloperMode = options.DeveloperMode;
}
if (!string.IsNullOrEmpty(options.EndpointAddress))
{
o.EndpointAddress = options.EndpointAddress;
}
if (!string.IsNullOrEmpty(options.InstrumentationKey))
{
o.InstrumentationKey = options.InstrumentationKey;
}
o.ApplicationVersion = options.ApplicationVersion;
o.EnableAdaptiveSampling = options.EnableAdaptiveSampling;
o.EnableDebugLogger = options.EnableDebugLogger;
o.EnableQuickPulseMetricStream = options.EnableQuickPulseMetricStream;
o.EnableHeartbeat = options.EnableHeartbeat;
o.AddAutoCollectedMetricExtractor = options.AddAutoCollectedMetricExtractor;
o.EnablePerformanceCounterCollectionModule = options.EnablePerformanceCounterCollectionModule;
o.EnableDependencyTrackingTelemetryModule = options.EnableDependencyTrackingTelemetryModule;
o.EnableAppServicesHeartbeatTelemetryModule = options.EnableAppServicesHeartbeatTelemetryModule;
o.EnableAzureInstanceMetadataTelemetryModule = options.EnableAzureInstanceMetadataTelemetryModule;
#if NETSTANDARD2_0
o.EnableEventCounterCollectionModule = options.EnableEventCounterCollectionModule;
#endif
#if AI_ASPNETCORE_WEB
o.EnableAuthenticationTrackingJavaScript = options.EnableAuthenticationTrackingJavaScript;
o.EnableRequestTrackingTelemetryModule = options.EnableRequestTrackingTelemetryModule;
#endif
});
}
private static void AddApplicationInsightsLoggerProvider(IServiceCollection services)
{

Просмотреть файл

@ -138,10 +138,45 @@
public bool EnableAuthenticationTrackingJavaScript { get; set; }
#endif
/// <summary>
/// Gets <see cref="DependencyCollectionOptions"/> that allow to manage <see cref="DependencyTrackingTelemetryModule"/>
/// </summary>
public DependencyCollectionOptions DependencyCollectionOptions { get; }
internal void CopyPropertiesTo(ApplicationInsightsServiceOptions target)
{
if (this.DeveloperMode != null)
{
target.DeveloperMode = this.DeveloperMode;
}
if (!string.IsNullOrEmpty(this.EndpointAddress))
{
target.EndpointAddress = this.EndpointAddress;
}
if (!string.IsNullOrEmpty(this.InstrumentationKey))
{
target.InstrumentationKey = this.InstrumentationKey;
}
target.ApplicationVersion = this.ApplicationVersion;
target.EnableAdaptiveSampling = this.EnableAdaptiveSampling;
target.EnableDebugLogger = this.EnableDebugLogger;
target.EnableQuickPulseMetricStream = this.EnableQuickPulseMetricStream;
target.EnableHeartbeat = this.EnableHeartbeat;
target.AddAutoCollectedMetricExtractor = this.AddAutoCollectedMetricExtractor;
target.EnablePerformanceCounterCollectionModule = this.EnablePerformanceCounterCollectionModule;
target.EnableDependencyTrackingTelemetryModule = this.EnableDependencyTrackingTelemetryModule;
target.EnableAppServicesHeartbeatTelemetryModule = this.EnableAppServicesHeartbeatTelemetryModule;
target.EnableAzureInstanceMetadataTelemetryModule = this.EnableAzureInstanceMetadataTelemetryModule;
#if NETSTANDARD2_0
target.EnableEventCounterCollectionModule = this.EnableEventCounterCollectionModule;
#endif
#if AI_ASPNETCORE_WEB
target.EnableAuthenticationTrackingJavaScript = this.EnableAuthenticationTrackingJavaScript;
target.EnableRequestTrackingTelemetryModule = this.EnableRequestTrackingTelemetryModule;
#endif
}
}
}