Skip to content
代码片段 群组 项目
未验证 提交 c9fabaef 编辑于 作者: James Newton-King's avatar James Newton-King 提交者: GitHub
浏览文件

Annotate hosting diagnostic events with DynamicDependency (#42512)

上级 93ee839f
No related branches found
No related tags found
无相关合并请求
......@@ -224,7 +224,7 @@ internal sealed class HostingApplicationDiagnostics
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026",
Justification = "The values being passed into Write have the commonly used properties being preserved with DynamicDependency.")]
private static void WriteDiagnosticEvent<TValue>(
private static void WriteDiagnosticEvent<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TValue>(
DiagnosticSource diagnosticSource, string name, TValue value)
{
diagnosticSource.Write(name, value);
......@@ -413,6 +413,19 @@ internal sealed class HostingApplicationDiagnostics
}
// These are versions of DiagnosticSource.Start/StopActivity that don't allocate strings per call (see https://github.com/dotnet/corefx/issues/37055)
// DynamicDependency matches the properties selected in:
// https://github.com/dotnet/diagnostics/blob/7cc6fbef613cdfe5ff64393120d59d7a15e98bd6/src/Microsoft.Diagnostics.Monitoring.EventPipe/Configuration/HttpRequestSourceConfiguration.cs#L20-L33
[DynamicDependency(nameof(HttpContext.Request), typeof(HttpContext))]
[DynamicDependency(nameof(HttpRequest.Scheme), typeof(HttpRequest))]
[DynamicDependency(nameof(HttpRequest.Host), typeof(HttpRequest))]
[DynamicDependency(nameof(HttpRequest.PathBase), typeof(HttpRequest))]
[DynamicDependency(nameof(HttpRequest.QueryString), typeof(HttpRequest))]
[DynamicDependency(nameof(HttpRequest.Path), typeof(HttpRequest))]
[DynamicDependency(nameof(HttpRequest.Method), typeof(HttpRequest))]
[DynamicDependency(nameof(HttpRequest.Headers), typeof(HttpRequest))]
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(QueryString))]
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(HostString))]
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(PathString))]
private Activity StartActivity(Activity activity, HttpContext httpContext)
{
activity.Start();
......@@ -420,6 +433,11 @@ internal sealed class HostingApplicationDiagnostics
return activity;
}
// DynamicDependency matches the properties selected in:
// https://github.com/dotnet/diagnostics/blob/7cc6fbef613cdfe5ff64393120d59d7a15e98bd6/src/Microsoft.Diagnostics.Monitoring.EventPipe/Configuration/HttpRequestSourceConfiguration.cs#L35-L38
[DynamicDependency(nameof(HttpContext.Response), typeof(HttpContext))]
[DynamicDependency(nameof(HttpResponse.StatusCode), typeof(HttpResponse))]
[DynamicDependency(nameof(HttpResponse.Headers), typeof(HttpResponse))]
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
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册