- Notifications
You must be signed in to change notification settings - Fork 296
/
Copy pathApplicationInsightsServiceOptions.cs
194 lines (167 loc) · 9.51 KB
/
ApplicationInsightsServiceOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#if AI_ASPNETCORE_WEB
namespaceMicrosoft.ApplicationInsights.AspNetCore.Extensions
#else
namespaceMicrosoft.ApplicationInsights.WorkerService
#endif
{
usingSystem.Reflection;
usingMicrosoft.ApplicationInsights.DependencyCollector;
/// <summary>
/// Application Insights service options defines the custom behavior of the features to add, as opposed to the default selection of features obtained from Application Insights.
/// </summary>
publicclassApplicationInsightsServiceOptions
{
/// <summary>
/// Gets or sets a value indicating whether QuickPulseTelemetryModule and QuickPulseTelemetryProcessor are registered with the configuration.
/// Setting EnableQuickPulseMetricStream to <value>false</value>, will disable the default quick pulse metric stream. Defaults to <value>true</value>.
/// </summary>
publicboolEnableQuickPulseMetricStream{get;set;}=true;
/// <summary>
/// Gets or sets a value indicating whether PerformanceCollectorModule should be enabled.
/// Defaults to <value>true</value>.
/// </summary>
publicboolEnablePerformanceCounterCollectionModule{get;set;}=true;
/// <summary>
/// Gets or sets a value indicating whether AppServicesHeartbeatTelemetryModule should be enabled.
/// Defaults to <value>true</value>.
/// IMPORTANT: This setting will be ignored if either <see cref="EnableDiagnosticsTelemetryModule"/> or <see cref="EnableHeartbeat"/> are set to false.
/// </summary>
publicboolEnableAppServicesHeartbeatTelemetryModule{get;set;}=true;
/// <summary>
/// Gets or sets a value indicating whether AzureInstanceMetadataTelemetryModule should be enabled.
/// Defaults to <value>true</value>.
/// IMPORTANT: This setting will be ignored if either <see cref="EnableDiagnosticsTelemetryModule"/> or <see cref="EnableHeartbeat"/> are set to false.
/// </summary>
publicboolEnableAzureInstanceMetadataTelemetryModule{get;set;}=true;
/// <summary>
/// Gets or sets a value indicating whether DependencyTrackingTelemetryModule should be enabled.
/// Defaults to <value>true</value>.
/// </summary>
publicboolEnableDependencyTrackingTelemetryModule{get;set;}=true;
/// <summary>
/// Gets or sets a value indicating whether EventCounterCollectionModule should be enabled.
/// Defaults to <value>true</value>.
/// </summary>
publicboolEnableEventCounterCollectionModule{get;set;}=true;
/// <summary>
/// Gets or sets a value indicating whether telemetry processor that controls sampling is added to the service.
/// Setting EnableAdaptiveSampling to <value>false</value>, will disable the default adaptive sampling feature. Defaults to <value>true</value>.
/// </summary>
publicboolEnableAdaptiveSampling{get;set;}=true;
/// <summary>
/// Gets or sets the default instrumentation key for the application.
/// </summary>
publicstringInstrumentationKey{get;set;}
/// <summary>
/// Gets or sets the connection string for the application.
/// </summary>
publicstringConnectionString{get;set;}
/// <summary>
/// Gets or sets the application version reported with telemetries.
/// </summary>
publicstringApplicationVersion{get;set;}=Assembly.GetEntryAssembly()?.GetName().Version.ToString();
/// <summary>
/// Gets or sets a value indicating whether telemetry channel should be set to developer mode.
/// </summary>
publicbool?DeveloperMode{get;set;}
/// <summary>
/// Gets or sets the endpoint address of the channel.
/// </summary>
publicstringEndpointAddress{get;set;}
/// <summary>
/// Gets or sets a value indicating whether a logger would be registered automatically in debug mode.
/// </summary>
publicboolEnableDebugLogger{get;set;}=true;
/// <summary>
/// Gets or sets a value indicating whether heartbeats are enabled.
/// IMPORTANT: This setting will be ignored if <see cref="EnableDiagnosticsTelemetryModule"/> is set to false.
/// IMPORTANT: Disabling this will cause the following settings to be ignored:
/// <see cref="EnableAzureInstanceMetadataTelemetryModule"/>.
/// <see cref="EnableAppServicesHeartbeatTelemetryModule"/>.
/// </summary>
publicboolEnableHeartbeat{get;set;}=true;
/// <summary>
/// Gets or sets a value indicating whether AutoCollectedMetricExtractors are added or not.
/// Defaults to <value>true</value>.
/// </summary>
publicboolAddAutoCollectedMetricExtractor{get;set;}=true;
#if AI_ASPNETCORE_WEB
/// <summary>
/// Gets <see cref="RequestCollectionOptions"/> that allow to manage <see cref="RequestTrackingTelemetryModule"/>.
/// </summary>
publicRequestCollectionOptionsRequestCollectionOptions{get;}=newRequestCollectionOptions();
/// <summary>
/// Gets or sets a value indicating whether RequestTrackingTelemetryModule should be enabled.
/// Defaults to <value>true</value>.
/// </summary>
publicboolEnableRequestTrackingTelemetryModule{get;set;}=true;
/// <summary>
/// Gets or sets a value indicating whether a JavaScript snippet to track the current authenticated user should
/// be printed along with the main ApplicationInsights tracking script.
/// </summary>
publicboolEnableAuthenticationTrackingJavaScript{get;set;}=false;
#endif
/// <summary>
/// Gets or sets a value indicating whether the <see cref="Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule"/> should be enabled.
/// IMPORTANT: Disabling this will cause the following settings to be ignored:
/// <see cref="EnableHeartbeat"/>.
/// <see cref="EnableAzureInstanceMetadataTelemetryModule"/>.
/// <see cref="EnableAppServicesHeartbeatTelemetryModule"/>.
/// </summary>
publicboolEnableDiagnosticsTelemetryModule{get;set;}=true;
/// <summary>
/// Gets <see cref="DependencyCollectionOptions"/> that allow to manage <see cref="DependencyTrackingTelemetryModule"/>.
/// </summary>
publicDependencyCollectionOptionsDependencyCollectionOptions{get;}=newDependencyCollectionOptions();
#if AI_ASPNETCORE_WEB
/// <summary>
/// Gets or sets a value indicating whether TelemetryConfiguration.Active should be initialized.
/// Former versions of this library had a dependency on this static instance.
/// This dependency has been removed and we no longer initialize this by default.
/// If users depended on this behavior you should enable this.
/// However, we recommend migrating away from using TelemetryConfiguration.Active in your projects.
/// </summary>
publicboolEnableActiveTelemetryConfigurationSetup{get;set;}=false;
#endif
/// <summary>
/// Copy the properties from this <see cref="ApplicationInsightsServiceOptions"/> to a target instance.
/// </summary>
/// <param name="target">Target instance to copy properties to.</param>
internalvoidCopyPropertiesTo(ApplicationInsightsServiceOptionstarget)
{
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;
}
if(!string.IsNullOrEmpty(this.ConnectionString))
{
target.ConnectionString=this.ConnectionString;
}
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;
target.EnableDiagnosticsTelemetryModule=this.EnableDiagnosticsTelemetryModule;
target.EnableEventCounterCollectionModule=this.EnableEventCounterCollectionModule;
#if AI_ASPNETCORE_WEB
target.EnableAuthenticationTrackingJavaScript=this.EnableAuthenticationTrackingJavaScript;
target.EnableRequestTrackingTelemetryModule=this.EnableRequestTrackingTelemetryModule;
target.EnableActiveTelemetryConfigurationSetup=this.EnableActiveTelemetryConfigurationSetup;
#endif
}
}
}