From 93d88ac001b54db169aec5c088a8469309aaf30e Mon Sep 17 00:00:00 2001 From: James Newton-King <james@newtonking.com> Date: Wed, 6 Jul 2022 14:02:03 +0800 Subject: [PATCH] Include DefaultHttpContext.HttpContext for diagnostic activities (#42591) --- .../Hosting/src/Internal/HostingApplicationDiagnostics.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs index d2a3e936572..381a63847b2 100644 --- a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs +++ b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs @@ -426,6 +426,8 @@ internal sealed class HostingApplicationDiagnostics [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(QueryString))] [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(HostString))] [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(PathString))] + // OpenTelemetry gets the context from the context using the DefaultHttpContext.HttpContext property. + [DynamicDependency(nameof(DefaultHttpContext.HttpContext), typeof(DefaultHttpContext))] private Activity StartActivity(Activity activity, HttpContext httpContext) { activity.Start(); @@ -438,6 +440,8 @@ internal sealed class HostingApplicationDiagnostics [DynamicDependency(nameof(HttpContext.Response), typeof(HttpContext))] [DynamicDependency(nameof(HttpResponse.StatusCode), typeof(HttpResponse))] [DynamicDependency(nameof(HttpResponse.Headers), typeof(HttpResponse))] + // OpenTelemetry gets the context from the context using the DefaultHttpContext.HttpContext property. + [DynamicDependency(nameof(DefaultHttpContext.HttpContext), typeof(DefaultHttpContext))] private void StopActivity(Activity activity, HttpContext httpContext) { // Stop sets the end time if it was unset, but we want it set before we issue the write -- GitLab