From d104b0398a41383f5f931e215df405af279dfe0d Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 18 Aug 2020 20:15:53 -0700 Subject: [PATCH 1/3] Added raw objects available to instrumentation as Activity custom properties. --- .../Implementation/GrpcClientDiagnosticListener.cs | 1 + .../Implementation/HttpHandlerDiagnosticListener.cs | 6 +++++- .../Implementation/SqlClientDiagnosticListener.cs | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.Grpc/Implementation/GrpcClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Grpc/Implementation/GrpcClientDiagnosticListener.cs index b0e51f52055..b89c4cc72a4 100644 --- a/src/OpenTelemetry.Instrumentation.Grpc/Implementation/GrpcClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Grpc/Implementation/GrpcClientDiagnosticListener.cs @@ -48,6 +48,7 @@ public override void OnStartActivity(Activity activity, object payload) activity.SetKind(ActivityKind.Client); activity.DisplayName = grpcMethod?.Trim('/'); + activity.SetCustomProperty("GrpcHandler.Request", request); this.activitySource.Start(activity); diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index c30c1ccd28d..4c9951afa5e 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs @@ -90,6 +90,7 @@ public override void OnStartActivity(Activity activity, object payload) activity.SetKind(ActivityKind.Client); activity.DisplayName = HttpTagHelper.GetOperationNameForHttpMethod(request.Method); + activity.SetCustomProperty("HttpHandler.Request", request); this.activitySource.Start(activity); @@ -135,7 +136,8 @@ public override void OnStopActivity(Activity activity, object payload) if (this.stopResponseFetcher.Fetch(payload) is HttpResponseMessage response) { - // response could be null for DNS issues, timeouts, etc... + activity.SetCustomProperty("HttpHandler.Response", response); + activity.SetTag(SemanticConventions.AttributeHttpStatusCode, (int)response.StatusCode); activity.SetStatus( @@ -158,6 +160,8 @@ public override void OnException(Activity activity, object payload) return; } + activity.SetCustomProperty("HttpHandler.Exception", exc); + if (exc is HttpRequestException) { if (exc.InnerException is SocketException exception) diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs index c2e5e099424..4e28b900e06 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs @@ -85,6 +85,7 @@ public override void OnCustom(string name, Activity activity, object payload) var database = this.databaseFetcher.Fetch(connection); activity.DisplayName = (string)database; + activity.SetCustomProperty("SqlHandler.Command", command); if (activity.IsAllDataRequested) { From cd8ea2c24d1a6f38c86e6ef14798392ad3d6d4bf Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 18 Aug 2020 20:22:23 -0700 Subject: [PATCH 2/3] Updated CHANGELOGs. --- src/OpenTelemetry.Instrumentation.Grpc/CHANGELOG.md | 4 ++++ src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md | 3 +++ src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.Grpc/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Grpc/CHANGELOG.md index 952aac4a905..3f877e11ad3 100644 --- a/src/OpenTelemetry.Instrumentation.Grpc/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Grpc/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +* Grpc instrumentation will now add the raw Request object to the Activity it + creates + ([#1099](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1099)) + ## 0.4.0-beta.2 Released 2020-07-24 diff --git a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md index df3a092b994..81225c11001 100644 --- a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* ASP.NET Core instrumentation will now add the raw Request, Response, and/or + Exception objects to the Activity it creates + ([#1099](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1099)) * Changed the default propagation to support W3C Baggage ([#1048](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1048)) * The default ITextFormat is now `CompositePropagator(TraceContextFormat, diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md index 2f00a9e597a..5f25df2bb31 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md @@ -2,7 +2,11 @@ ## Unreleased -* Renamed from `AddSqlClientDependencyInstrumentation` to `AddSqlClientInstrumentation` +* .NET Core SqlClient instrumentation will now add the raw Command object to the + Activity it creates + ([#1099](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1099)) +* Renamed from `AddSqlClientDependencyInstrumentation` to + `AddSqlClientInstrumentation` ## 0.4.0-beta.2 From 0375f04cbe3844cb73feaafe41b511590c9fd215 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 18 Aug 2020 21:19:12 -0700 Subject: [PATCH 3/3] Added "OTel" prefix to custom properties. Moved to constants. --- .../Implementation/HttpInListener.cs | 8 +++--- .../GrpcClientDiagnosticListener.cs | 4 ++- .../HttpHandlerDiagnosticListener.cs | 10 +++++-- .../HttpWebRequestActivitySource.netfx.cs | 14 ++++++---- .../SqlClientDiagnosticListener.cs | 22 ++++++++------- src/OpenTelemetry/Trace/ActivityExtensions.cs | 2 +- ...HttpWebRequestActivitySourceTests.netfx.cs | 28 +++++++++---------- 7 files changed, 50 insertions(+), 38 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs index bab7424db80..7435c752dfe 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs @@ -78,8 +78,8 @@ public override void OnStartActivity(Activity activity, object payload) // Both new activity and old one store the other activity // inside them. This is required in the Stop step to // correctly stop and restore Activity.Current. - newOne.SetCustomProperty("ActivityByAspNet", activity); - activity.SetCustomProperty("ActivityByHttpInListener", newOne); + newOne.SetCustomProperty("OTel.ActivityByAspNet", activity); + activity.SetCustomProperty("OTel.ActivityByHttpInListener", newOne); activity = newOne; } @@ -135,7 +135,7 @@ public override void OnStopActivity(Activity activity, object payload) // This block is hit if Asp.Net did restore Current to its own activity, // and we need to retrieve the one created by HttpInListener, // or an additional activity was never created. - createdActivity = (Activity)activity.GetCustomProperty("ActivityByHttpInListener"); + createdActivity = (Activity)activity.GetCustomProperty("OTel.ActivityByHttpInListener"); activityToEnrich = createdActivity ?? activity; } } @@ -196,7 +196,7 @@ public override void OnStopActivity(Activity activity, object payload) activity.Stop(); // Restore the original activity as Current. - var activityByAspNet = (Activity)activity.GetCustomProperty("ActivityByAspNet"); + var activityByAspNet = (Activity)activity.GetCustomProperty("OTel.ActivityByAspNet"); Activity.Current = activityByAspNet; } else if (createdActivity != null) diff --git a/src/OpenTelemetry.Instrumentation.Grpc/Implementation/GrpcClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Grpc/Implementation/GrpcClientDiagnosticListener.cs index b89c4cc72a4..f66ebf7e194 100644 --- a/src/OpenTelemetry.Instrumentation.Grpc/Implementation/GrpcClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Grpc/Implementation/GrpcClientDiagnosticListener.cs @@ -22,6 +22,8 @@ namespace OpenTelemetry.Instrumentation.Grpc.Implementation { internal class GrpcClientDiagnosticListener : ListenerHandler { + public const string RequestCustomPropertyName = "OTel.GrpcHandler.Request"; + private readonly ActivitySourceAdapter activitySource; private readonly PropertyFetcher startRequestFetcher = new PropertyFetcher("Request"); @@ -48,7 +50,7 @@ public override void OnStartActivity(Activity activity, object payload) activity.SetKind(ActivityKind.Client); activity.DisplayName = grpcMethod?.Trim('/'); - activity.SetCustomProperty("GrpcHandler.Request", request); + activity.SetCustomProperty(RequestCustomPropertyName, request); this.activitySource.Start(activity); diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index 4c9951afa5e..c0a761ccc63 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs @@ -29,6 +29,10 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation { internal class HttpHandlerDiagnosticListener : ListenerHandler { + public const string RequestCustomPropertyName = "OTel.HttpHandler.Request"; + public const string ResponseCustomPropertyName = "OTel.HttpHandler.Response"; + public const string ExceptionCustomPropertyName = "OTel.HttpHandler.Exception"; + private static readonly Func> HttpRequestMessageHeaderValuesGetter = (request, name) => { if (request.Headers.TryGetValues(name, out var values)) @@ -90,7 +94,7 @@ public override void OnStartActivity(Activity activity, object payload) activity.SetKind(ActivityKind.Client); activity.DisplayName = HttpTagHelper.GetOperationNameForHttpMethod(request.Method); - activity.SetCustomProperty("HttpHandler.Request", request); + activity.SetCustomProperty(RequestCustomPropertyName, request); this.activitySource.Start(activity); @@ -136,7 +140,7 @@ public override void OnStopActivity(Activity activity, object payload) if (this.stopResponseFetcher.Fetch(payload) is HttpResponseMessage response) { - activity.SetCustomProperty("HttpHandler.Response", response); + activity.SetCustomProperty(ResponseCustomPropertyName, response); activity.SetTag(SemanticConventions.AttributeHttpStatusCode, (int)response.StatusCode); @@ -160,7 +164,7 @@ public override void OnException(Activity activity, object payload) return; } - activity.SetCustomProperty("HttpHandler.Exception", exc); + activity.SetCustomProperty(ExceptionCustomPropertyName, exc); if (exc is HttpRequestException) { diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpWebRequestActivitySource.netfx.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpWebRequestActivitySource.netfx.cs index 62e3634f07f..8d7842cc985 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpWebRequestActivitySource.netfx.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpWebRequestActivitySource.netfx.cs @@ -37,8 +37,12 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation /// internal static class HttpWebRequestActivitySource { - internal const string ActivitySourceName = "OpenTelemetry.HttpWebRequest"; - internal const string ActivityName = ActivitySourceName + ".HttpRequestOut"; + public const string ActivitySourceName = "OpenTelemetry.HttpWebRequest"; + public const string ActivityName = ActivitySourceName + ".HttpRequestOut"; + + public const string RequestCustomPropertyName = "OTel.HttpWebRequest.Request"; + public const string ResponseCustomPropertyName = "OTel.HttpWebRequest.Response"; + public const string ExceptionCustomPropertyName = "OTel.HttpWebRequest.Exception"; internal static readonly Func> HttpWebRequestHeaderValuesGetter = (request, name) => request.Headers.GetValues(name); internal static readonly Action HttpWebRequestHeaderValuesSetter = (request, name, value) => request.Headers.Add(name, value); @@ -97,7 +101,7 @@ private static void AddRequestTagsAndInstrumentRequest(HttpWebRequest request, A InstrumentRequest(request, activity); - activity.SetCustomProperty("HttpWebRequest.Request", request); + activity.SetCustomProperty(RequestCustomPropertyName, request); if (activity.IsAllDataRequested) { @@ -114,7 +118,7 @@ private static void AddRequestTagsAndInstrumentRequest(HttpWebRequest request, A [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void AddResponseTags(HttpWebResponse response, Activity activity) { - activity.SetCustomProperty("HttpWebRequest.Response", response); + activity.SetCustomProperty(ResponseCustomPropertyName, response); if (activity.IsAllDataRequested) { @@ -130,7 +134,7 @@ private static void AddResponseTags(HttpWebResponse response, Activity activity) [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void AddExceptionTags(Exception exception, Activity activity) { - activity.SetCustomProperty("HttpWebRequest.Exception", exception); + activity.SetCustomProperty(ExceptionCustomPropertyName, exception); if (!activity.IsAllDataRequested) { diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs index 4e28b900e06..44def927ae4 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs @@ -22,19 +22,21 @@ namespace OpenTelemetry.Instrumentation.SqlClient.Implementation { internal class SqlClientDiagnosticListener : ListenerHandler { - internal const string ActivitySourceName = "OpenTelemetry.SqlClient"; - internal const string ActivityName = ActivitySourceName + ".Execute"; + public const string ActivitySourceName = "OpenTelemetry.SqlClient"; + public const string ActivityName = ActivitySourceName + ".Execute"; - internal const string SqlDataBeforeExecuteCommand = "System.Data.SqlClient.WriteCommandBefore"; - internal const string SqlMicrosoftBeforeExecuteCommand = "Microsoft.Data.SqlClient.WriteCommandBefore"; + public const string CommandCustomPropertyName = "OTel.SqlHandler.Command"; - internal const string SqlDataAfterExecuteCommand = "System.Data.SqlClient.WriteCommandAfter"; - internal const string SqlMicrosoftAfterExecuteCommand = "Microsoft.Data.SqlClient.WriteCommandAfter"; + public const string SqlDataBeforeExecuteCommand = "System.Data.SqlClient.WriteCommandBefore"; + public const string SqlMicrosoftBeforeExecuteCommand = "Microsoft.Data.SqlClient.WriteCommandBefore"; - internal const string SqlDataWriteCommandError = "System.Data.SqlClient.WriteCommandError"; - internal const string SqlMicrosoftWriteCommandError = "Microsoft.Data.SqlClient.WriteCommandError"; + public const string SqlDataAfterExecuteCommand = "System.Data.SqlClient.WriteCommandAfter"; + public const string SqlMicrosoftAfterExecuteCommand = "Microsoft.Data.SqlClient.WriteCommandAfter"; - internal const string MicrosoftSqlServerDatabaseSystemName = "mssql"; + public const string SqlDataWriteCommandError = "System.Data.SqlClient.WriteCommandError"; + public const string SqlMicrosoftWriteCommandError = "Microsoft.Data.SqlClient.WriteCommandError"; + + public const string MicrosoftSqlServerDatabaseSystemName = "mssql"; private static readonly Version Version = typeof(SqlClientDiagnosticListener).Assembly.GetName().Version; #pragma warning disable SA1202 // Elements should be ordered by access <- In this case, Version MUST come before SqlClientActivitySource otherwise null ref exception is thrown. @@ -85,7 +87,7 @@ public override void OnCustom(string name, Activity activity, object payload) var database = this.databaseFetcher.Fetch(connection); activity.DisplayName = (string)database; - activity.SetCustomProperty("SqlHandler.Command", command); + activity.SetCustomProperty(CommandCustomPropertyName, command); if (activity.IsAllDataRequested) { diff --git a/src/OpenTelemetry/Trace/ActivityExtensions.cs b/src/OpenTelemetry/Trace/ActivityExtensions.cs index 351426ff119..ad31b8f1226 100644 --- a/src/OpenTelemetry/Trace/ActivityExtensions.cs +++ b/src/OpenTelemetry/Trace/ActivityExtensions.cs @@ -23,7 +23,7 @@ namespace OpenTelemetry.Trace /// public static class ActivityExtensions { - internal const string ResourcePropertyName = "otel.resource"; + internal const string ResourcePropertyName = "OTel.Resource"; /// /// Gets the Resource associated with the Activity. diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs index 346041176f3..22f8a606606 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs @@ -185,7 +185,7 @@ public async Task TestBasicReceiveAndResponseEvents(string method, string queryS Assert.True(eventRecords.Records.TryDequeue(out var stopEvent)); Assert.Equal("Stop", stopEvent.Key); - HttpWebResponse response = (HttpWebResponse)stopEvent.Value.GetCustomProperty("HttpWebRequest.Response"); + HttpWebResponse response = (HttpWebResponse)stopEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.ResponseCustomPropertyName); Assert.NotNull(response); VerifyActivityStopTags(200, "OK", activity); @@ -237,7 +237,7 @@ public async Task TestBasicReceiveAndResponseEventsWitPassThroughSampling(string Assert.True(eventRecords.Records.TryDequeue(out var stopEvent)); Assert.Equal("Stop", stopEvent.Key); - HttpWebResponse response = (HttpWebResponse)stopEvent.Value.GetCustomProperty("HttpWebRequest.Response"); + HttpWebResponse response = (HttpWebResponse)stopEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.ResponseCustomPropertyName); Assert.NotNull(response); Assert.Empty(activity.Tags); @@ -401,7 +401,7 @@ public async Task TestBasicReceiveAndResponseWebRequestEvents(string method, int Assert.True(eventRecords.Records.TryDequeue(out var stopEvent)); Assert.Equal("Stop", stopEvent.Key); - HttpWebResponse response = (HttpWebResponse)stopEvent.Value.GetCustomProperty("HttpWebRequest.Response"); + HttpWebResponse response = (HttpWebResponse)stopEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.ResponseCustomPropertyName); Assert.NotNull(response); VerifyActivityStopTags(200, "OK", activity); @@ -518,9 +518,9 @@ public async Task TestResponseWithoutContentEvents(string method) Assert.True(eventRecords.Records.TryDequeue(out var stopEvent)); Assert.Equal("Stop", stopEvent.Key); - HttpWebRequest stopRequest = (HttpWebRequest)stopEvent.Value.GetCustomProperty("HttpWebRequest.Request"); + HttpWebRequest stopRequest = (HttpWebRequest)stopEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.RequestCustomPropertyName); Assert.Equal(startRequest, stopRequest); - HttpWebResponse stopResponse = (HttpWebResponse)stopEvent.Value.GetCustomProperty("HttpWebRequest.Response"); + HttpWebResponse stopResponse = (HttpWebResponse)stopEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.ResponseCustomPropertyName); Assert.NotNull(stopResponse); VerifyActivityStopTags(204, "No Content", activity); @@ -587,9 +587,9 @@ public async Task TestRequestWithException(string method) Assert.True(eventRecords.Records.TryDequeue(out KeyValuePair exceptionEvent)); Assert.Equal("Stop", exceptionEvent.Key); - HttpWebRequest exceptionRequest = (HttpWebRequest)exceptionEvent.Value.GetCustomProperty("HttpWebRequest.Request"); + HttpWebRequest exceptionRequest = (HttpWebRequest)exceptionEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.RequestCustomPropertyName); Assert.Equal(startRequest, exceptionRequest); - Exception exceptionException = (Exception)exceptionEvent.Value.GetCustomProperty("HttpWebRequest.Exception"); + Exception exceptionException = (Exception)exceptionEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.ExceptionCustomPropertyName); Assert.Equal(webException, exceptionException); Assert.Contains(activity.Tags, i => i.Key == SpanAttributeConstants.StatusCodeKey); @@ -631,7 +631,7 @@ public async Task TestCanceledRequest(string method) Assert.True(eventRecords.Records.TryDequeue(out KeyValuePair exceptionEvent)); Assert.Equal("Stop", exceptionEvent.Key); - Exception exceptionException = (Exception)exceptionEvent.Value.GetCustomProperty("HttpWebRequest.Exception"); + Exception exceptionException = (Exception)exceptionEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.ExceptionCustomPropertyName); Assert.Contains(exceptionEvent.Value.Tags, i => i.Key == SpanAttributeConstants.StatusCodeKey); Assert.DoesNotContain(exceptionEvent.Value.Tags, i => i.Key == SpanAttributeConstants.StatusDescriptionKey); @@ -672,7 +672,7 @@ public async Task TestSecureTransportFailureRequest(string method) Assert.True(eventRecords.Records.TryDequeue(out KeyValuePair exceptionEvent)); Assert.Equal("Stop", exceptionEvent.Key); - Exception exceptionException = (Exception)exceptionEvent.Value.GetCustomProperty("HttpWebRequest.Exception"); + Exception exceptionException = (Exception)exceptionEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.ExceptionCustomPropertyName); Assert.Contains(exceptionEvent.Value.Tags, i => i.Key == SpanAttributeConstants.StatusCodeKey); Assert.Contains(exceptionEvent.Value.Tags, i => i.Key == SpanAttributeConstants.StatusDescriptionKey); @@ -716,7 +716,7 @@ public async Task TestSecureTransportRetryFailureRequest(string method) Assert.True(eventRecords.Records.TryDequeue(out KeyValuePair exceptionEvent)); Assert.Equal("Stop", exceptionEvent.Key); - Exception exceptionException = (Exception)exceptionEvent.Value.GetCustomProperty("HttpWebRequest.Exception"); + Exception exceptionException = (Exception)exceptionEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.ExceptionCustomPropertyName); Assert.Contains(exceptionEvent.Value.Tags, i => i.Key == SpanAttributeConstants.StatusCodeKey); Assert.Contains(exceptionEvent.Value.Tags, i => i.Key == SpanAttributeConstants.StatusDescriptionKey); @@ -741,7 +741,7 @@ public async Task TestInvalidBaggage() Assert.Equal(1, eventRecords.Records.Count(rec => rec.Key == "Start")); Assert.Equal(1, eventRecords.Records.Count(rec => rec.Key == "Stop")); - WebRequest thisRequest = (WebRequest)eventRecords.Records.First().Value.GetCustomProperty("HttpWebRequest.Request"); + WebRequest thisRequest = (WebRequest)eventRecords.Records.First().Value.GetCustomProperty(HttpWebRequestActivitySource.RequestCustomPropertyName); string[] correlationContext = thisRequest.Headers["baggage"].Split(','); Assert.Equal(3, correlationContext.Length); @@ -809,7 +809,7 @@ public void TestMultipleConcurrentRequests() pair.Key == "Stop", "An unexpected event of name " + pair.Key + "was received"); - WebRequest request = (WebRequest)activity.GetCustomProperty("HttpWebRequest.Request"); + WebRequest request = (WebRequest)activity.GetCustomProperty(HttpWebRequestActivitySource.RequestCustomPropertyName); Assert.Equal("HttpWebRequest", request.GetType().Name); if (pair.Key == "Start") @@ -831,7 +831,7 @@ public void TestMultipleConcurrentRequests() else { // This must be the response. - WebResponse response = (WebResponse)activity.GetCustomProperty("HttpWebRequest.Response"); + WebResponse response = (WebResponse)activity.GetCustomProperty(HttpWebRequestActivitySource.ResponseCustomPropertyName); Assert.Equal("HttpWebResponse", response.GetType().Name); // By the time we see the response, the request object may already have been redirected with a different @@ -871,7 +871,7 @@ private static (Activity, HttpWebRequest) AssertFirstEventWasStart(ActivitySourc { Assert.True(eventRecords.Records.TryDequeue(out KeyValuePair startEvent)); Assert.Equal("Start", startEvent.Key); - HttpWebRequest startRequest = (HttpWebRequest)startEvent.Value.GetCustomProperty("HttpWebRequest.Request"); + HttpWebRequest startRequest = (HttpWebRequest)startEvent.Value.GetCustomProperty(HttpWebRequestActivitySource.RequestCustomPropertyName); Assert.NotNull(startRequest); return (startEvent.Value, startRequest); }