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

Commit e507902

Browse files
authored
Revert "Revert "Make W3C Correlation default and leverage native W3C support from new System.Diagnostics.DiagnosticSource Activity (#958)" (#962)"
This reverts commit c2929a9.
1 parent c2929a9 commit e507902

File tree

39 files changed

+1364
-1165
lines changed

39 files changed

+1364
-1165
lines changed

.vsts/linux-build.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,27 @@ steps:
2121
arguments: "--configuration Release"
2222

2323
- task: DotNetCoreCLI@1
24-
displayName: Test 2.0
24+
displayName: Functional Tests 2.0
2525
continueOnError: true
2626
inputs:
2727
command: "test"
2828
projects: "test/**/*Tests20.csproj"
2929
arguments: "--configuration Release -l trx"
3030

31-
- task: DotNetCoreInstaller@0
32-
displayName: install dotnet core 1.1.5
33-
inputs:
34-
version: "1.1.5"
35-
3631
- task: DotNetCoreCLI@1
37-
displayName: Test 1.1.5
32+
displayName: Unit Tests
3833
continueOnError: true
3934
inputs:
4035
command: "test"
41-
projects: "test/**/*Tests.csproj"
42-
arguments: "--configuration Release -l trx --filter Category!=WindowsOnly"
36+
projects: "test/**/*AspNetCore.Tests.csproj"
37+
arguments: "--configuration Release -l trx"
4338

4439

4540
- task: PublishTestResults@2
4641
inputs:
4742
testRunner: "VSTest"
4843
testResultsFiles: "**/*.trx"
4944

50-
- task: DotNetCoreInstaller@0
51-
displayName: install dotnet core 2.1.500
52-
inputs:
53-
version: "2.1.500"
54-
5545
- task: DotNetCoreCLI@1
5646
displayName: Package Nuget
5747
inputs:
@@ -63,4 +53,4 @@ steps:
6353
inputs:
6454
PathtoPublish: "$(build.artifactstagingdirectory)"
6555
ArtifactName: "drop"
66-
ArtifactType: "Container"
56+
ArtifactType: "Container"

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Version 2.8.0-beta3
4+
- [Make W3C Correlation default and leverage native W3C support from Activity.](https://github.com/microsoft/ApplicationInsights-aspnetcore/pull/958)
5+
- [Fixes Azure Functions performance degradation when W3C enabled.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/900)
6+
- [Fix: AppId is never set is Response Headers.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/956)
7+
38
## Version 2.8.0-beta2
49
- [Fix MVCBeforeAction property fetcher to work with .NET Core 3.0 changes.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/936)
510
- [Catch generic exception from DiagnosticSourceListeners and log instead of failing user request.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/957)

src/Microsoft.ApplicationInsights.AspNetCore/DiagnosticListeners/Implementation/ContextData.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/Microsoft.ApplicationInsights.AspNetCore/DiagnosticListeners/Implementation/HeadersUtilities.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public static StringValues SetHeaderKeyValue(string[] currentHeaders, string key
7272
/// Http Headers only allow Printable US-ASCII characters.
7373
/// Remove all other characters.
7474
/// </summary>
75+
/// <returns>sanitized string.</returns>
7576
public static string SanitizeString(string input)
7677
{
7778
if (string.IsNullOrWhiteSpace(input))

src/Microsoft.ApplicationInsights.AspNetCore/DiagnosticListeners/Implementation/HostingDiagnosticListener.cs

Lines changed: 392 additions & 339 deletions
Large diffs are not rendered by default.

src/Microsoft.ApplicationInsights.AspNetCore/DiagnosticListeners/Implementation/MvcDiagnosticsListener.cs

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ namespace Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners
99
using Microsoft.AspNetCore.Http;
1010

1111
/// <summary>
12-
/// <see cref="IApplicationInsightDiagnosticListener"/> implementation that listens for evens specific to AspNetCore Mvc layer
12+
/// <see cref="IApplicationInsightDiagnosticListener"/> implementation that listens for events specific to AspNetCore Mvc layer.
1313
/// </summary>
1414
[Obsolete("This class was merged with HostingDiagnosticsListener to optimize Diagnostics Source subscription performance")]
1515
public class MvcDiagnosticsListener : IApplicationInsightDiagnosticListener
1616
{
17-
/// <inheritdoc />
18-
public string ListenerName { get; } = "Microsoft.AspNetCore";
19-
2017
private readonly PropertyFetcher httpContextFetcher = new PropertyFetcher("httpContext");
2118
private readonly PropertyFetcher routeDataFetcher = new PropertyFetcher("routeData");
2219
private readonly PropertyFetcher routeValuesFetcher = new PropertyFetcher("Values");
2320

21+
/// <inheritdoc />
22+
public string ListenerName { get; } = "Microsoft.AspNetCore";
23+
2424
/// <summary>
25-
/// Diagnostic event handler method for 'Microsoft.AspNetCore.Mvc.BeforeAction' event
25+
/// Diagnostic event handler method for 'Microsoft.AspNetCore.Mvc.BeforeAction' event.
2626
/// </summary>
2727
public void OnBeforeAction(HttpContext httpContext, IDictionary<string, object> routeValues)
2828
{
@@ -40,6 +40,49 @@ public void OnBeforeAction(HttpContext httpContext, IDictionary<string, object>
4040
}
4141
}
4242

43+
/// <inheritdoc />
44+
public void OnSubscribe()
45+
{
46+
}
47+
48+
/// <inheritdoc />
49+
public void OnNext(KeyValuePair<string, object> value)
50+
{
51+
try
52+
{
53+
if (value.Key == "Microsoft.AspNetCore.Mvc.BeforeAction")
54+
{
55+
var context = this.httpContextFetcher.Fetch(value.Value) as HttpContext;
56+
var routeData = this.routeDataFetcher.Fetch(value.Value);
57+
var routeValues = this.routeValuesFetcher.Fetch(routeData) as IDictionary<string, object>;
58+
59+
if (context != null && routeValues != null)
60+
{
61+
this.OnBeforeAction(context, routeValues);
62+
}
63+
}
64+
}
65+
catch (Exception ex)
66+
{
67+
AspNetCoreEventSource.Instance.DiagnosticListenerWarning("MvcDiagnosticsListener", value.Key, ex.Message);
68+
}
69+
}
70+
71+
/// <inheritdoc />
72+
public void OnError(Exception error)
73+
{
74+
}
75+
76+
/// <inheritdoc />
77+
public void OnCompleted()
78+
{
79+
}
80+
81+
/// <inheritdoc />
82+
public void Dispose()
83+
{
84+
}
85+
4386
private string GetNameFromRouteContext(IDictionary<string, object> routeValues)
4487
{
4588
string name = null;
@@ -95,48 +138,5 @@ private string GetNameFromRouteContext(IDictionary<string, object> routeValues)
95138

96139
return name;
97140
}
98-
99-
/// <inheritdoc />
100-
public void OnSubscribe()
101-
{
102-
}
103-
104-
/// <inheritdoc />
105-
public void OnNext(KeyValuePair<string, object> value)
106-
{
107-
try
108-
{
109-
if (value.Key == "Microsoft.AspNetCore.Mvc.BeforeAction")
110-
{
111-
var context = this.httpContextFetcher.Fetch(value.Value) as HttpContext;
112-
var routeData = routeDataFetcher.Fetch(value.Value);
113-
var routeValues = routeValuesFetcher.Fetch(routeData) as IDictionary<string, object>;
114-
115-
if (context != null && routeValues != null)
116-
{
117-
this.OnBeforeAction(context, routeValues);
118-
}
119-
}
120-
}
121-
catch (Exception ex)
122-
{
123-
AspNetCoreEventSource.Instance.DiagnosticListenerWarning("MvcDiagnosticsListener", value.Key, ex.Message);
124-
}
125-
}
126-
127-
/// <inheritdoc />
128-
public void OnError(Exception error)
129-
{
130-
}
131-
132-
/// <inheritdoc />
133-
public void OnCompleted()
134-
{
135-
}
136-
137-
/// <inheritdoc />
138-
public void Dispose()
139-
{
140-
}
141141
}
142142
}

src/Microsoft.ApplicationInsights.AspNetCore/DiagnosticListeners/Implementation/RequestResponseHeaders.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,14 @@ internal static class RequestResponseHeaders
2929
/// Correlation-Context header.
3030
/// </summary>
3131
public const string CorrelationContextHeader = "Correlation-Context";
32+
33+
//
34+
// Summary:
35+
// W3C traceparent header name.
36+
public const string TraceParentHeader = "traceparent";
37+
//
38+
// Summary:
39+
// W3C tracestate header name.
40+
public const string TraceStateHeader = "tracestate";
3241
}
3342
}

src/Microsoft.ApplicationInsights.AspNetCore/Extensibility/Implementation/Tracing/AspNetCoreEventSource.cs

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,27 @@ public void LogHostingDiagnosticListenerOnHttpRequestInStartActivityNull(string
111111
this.WriteEvent(9, this.ApplicationName);
112112
}
113113

114+
/// <summary>
115+
/// Logs an event when a TelemetryModule is not found to configure.
116+
/// </summary>
114117
[Event(11, Message = "Unable to configure module {0} as it is not found in service collection.", Level = EventLevel.Warning, Keywords = Keywords.Diagnostics)]
115118
public void UnableToFindModuleToConfigure(string moduleType, string appDomainName = "Incorrect")
116119
{
117120
this.WriteEvent(11, moduleType, this.ApplicationName);
118121
}
119122

123+
/// <summary>
124+
/// Logs an event when QuickPulseTelemetryModule is not found in service collection.
125+
/// </summary>
120126
[Event(12, Message = "Unable to find QuickPulseTelemetryModule in service collection. LiveMetrics feature will not be available. Please add QuickPulseTelemetryModule to services collection in the ConfigureServices method of your application Startup class.", Level = EventLevel.Error, Keywords = Keywords.Diagnostics)]
121127
public void UnableToFindQuickPulseModuleInDI(string appDomainName = "Incorrect")
122128
{
123129
this.WriteEvent(12, this.ApplicationName);
124130
}
125131

132+
/// <summary>
133+
/// Logs an event when telemetry is not tracked as the Listener is not active.
134+
/// </summary>
126135
[Event(
127136
13,
128137
Keywords = Keywords.Diagnostics,
@@ -133,6 +142,9 @@ public void NotActiveListenerNoTracking(string evntName, string activityId, stri
133142
this.WriteEvent(13, evntName, activityId, this.ApplicationName);
134143
}
135144

145+
/// <summary>
146+
/// Logs an event for when generic error occur within the SDK.
147+
/// </summary>
136148
[Event(
137149
14,
138150
Keywords = Keywords.Diagnostics,
@@ -143,6 +155,9 @@ public void LogError(string errorMessage, string appDomainName = "Incorrect")
143155
this.WriteEvent(14, errorMessage, this.ApplicationName);
144156
}
145157

158+
/// <summary>
159+
/// Logs an event when RequestTrackingModule failed to initialize.
160+
/// </summary>
146161
[Event(
147162
15,
148163
Keywords = Keywords.Diagnostics,
@@ -153,6 +168,9 @@ public void RequestTrackingModuleInitializationFailed(string errorMessage, strin
153168
this.WriteEvent(15, errorMessage, this.ApplicationName);
154169
}
155170

171+
/// <summary>
172+
/// Logs an event when any error occurs within DiagnosticListener callback.
173+
/// </summary>
156174
[Event(
157175
16,
158176
Keywords = Keywords.Diagnostics,
@@ -163,6 +181,9 @@ public void DiagnosticListenerWarning(string callback, string errorMessage, stri
163181
this.WriteEvent(16, callback, errorMessage, this.ApplicationName);
164182
}
165183

184+
/// <summary>
185+
/// Logs an event when TelemetryConfiguration configure has failed.
186+
/// </summary>
166187
[Event(
167188
17,
168189
Keywords = Keywords.Diagnostics,
@@ -172,7 +193,10 @@ public void TelemetryConfigurationSetupFailure(string errorMessage, string appDo
172193
{
173194
this.WriteEvent(17, errorMessage, this.ApplicationName);
174195
}
175-
196+
197+
/// <summary>
198+
/// Logs an event when a telemetry item is sampled out at head.
199+
/// </summary>
176200
[Event(
177201
18,
178202
Keywords = Keywords.Diagnostics,
@@ -183,6 +207,42 @@ public void TelemetryItemWasSampledOutAtHead(string operationId, string appDomai
183207
this.WriteEvent(18, operationId, this.ApplicationName);
184208
}
185209

210+
/// <summary>
211+
/// Logs an informational event from Hosting listeners.
212+
/// </summary>
213+
[Event(
214+
19,
215+
Message = "Hosting Major Version: '{0}'. Informational Message: '{1}'.",
216+
Level = EventLevel.Informational)]
217+
public void HostingListenerInformational(string hostingVersion, string message, string appDomainName = "Incorrect")
218+
{
219+
this.WriteEvent(19, hostingVersion, message, this.ApplicationName);
220+
}
221+
222+
/// <summary>
223+
/// Logs a verbose event.
224+
/// </summary>
225+
[Event(
226+
20,
227+
Message = "Message: '{0}'.",
228+
Level = EventLevel.Verbose)]
229+
public void HostingListenerVerboe(string message, string appDomainName = "Incorrect")
230+
{
231+
this.WriteEvent(20, message, this.ApplicationName);
232+
}
233+
234+
/// <summary>
235+
/// Logs an event for RequestTelemetry created.
236+
/// </summary>
237+
[Event(
238+
21,
239+
Message = "RequestTelemetry created. CorrelationFormat: '{0}', RequestID: '{1}', OperationId : '{2}' ",
240+
Level = EventLevel.Informational)]
241+
public void RequestTelemetryCreated(string correlationFormat, string requestId, string requestOperationId, string appDomainName = "Incorrect")
242+
{
243+
this.WriteEvent(21, correlationFormat, requestId, requestOperationId, this.ApplicationName);
244+
}
245+
186246
/// <summary>
187247
/// Keywords for the AspNetEventSource.
188248
/// </summary>

0 commit comments

Comments
 (0)