Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Commit 37d8664

Browse files
committed
Addressed feedback
1 parent e251272 commit 37d8664

File tree

2 files changed

+19
-66
lines changed

2 files changed

+19
-66
lines changed

src/Microsoft.AspNetCore.Hosting/Internal/HostingApplication.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Context CreateContext(IFeatureCollection contextFeatures)
4343
_diagnosticSource.Write("Microsoft.AspNetCore.Hosting.BeginRequest", new { httpContext = httpContext, timestamp = startTimestamp });
4444
}
4545

46-
HostingEventSource.Log.RequestStart(httpContext);
46+
HostingEventSource.Log.RequestStart(httpContext.Request.Method, httpContext.Request.Path);
4747

4848
return new Context
4949
{
@@ -69,7 +69,7 @@ public void DisposeContext(Context context, Exception exception)
6969
_diagnosticSource.Write("Microsoft.AspNetCore.Hosting.EndRequest", new { httpContext = httpContext, timestamp = currentTimestamp });
7070
}
7171

72-
HostingEventSource.Log.RequestStop(httpContext);
72+
HostingEventSource.Log.RequestStop();
7373
}
7474
else
7575
{
@@ -83,7 +83,8 @@ public void DisposeContext(Context context, Exception exception)
8383
_diagnosticSource.Write("Microsoft.AspNetCore.Hosting.UnhandledException", new { httpContext = httpContext, timestamp = currentTimestamp, exception = exception });
8484
}
8585

86-
HostingEventSource.Log.RequestStop(httpContext, exception);
86+
HostingEventSource.Log.UnhandledException();
87+
HostingEventSource.Log.RequestStop();
8788
}
8889

8990
context.Scope?.Dispose();
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System;
5-
using System.Linq;
64
using System.Diagnostics.Tracing;
75
using Microsoft.AspNetCore.Http;
8-
using Microsoft.Net.Http.Headers;
96

107
namespace Microsoft.AspNetCore.Hosting.Internal
118
{
@@ -16,10 +13,12 @@ public sealed class HostingEventSource : EventSource
1613

1714
private HostingEventSource() { }
1815

19-
// The 'Start' and 'Stop' suffixes on the following event names have special meaning in EventSource. They
20-
// enable creating 'activities'.
21-
// For more information, take a look at the following blog post:
22-
// https://blogs.msdn.microsoft.com/vancem/2015/09/14/exploring-eventsource-activity-correlation-and-causation-features/
16+
// NOTE
17+
// - The 'Start' and 'Stop' suffixes on the following event names have special meaning in EventSource. They
18+
// enable creating 'activities'.
19+
// For more information, take a look at the following blog post:
20+
// https://blogs.msdn.microsoft.com/vancem/2015/09/14/exploring-eventsource-activity-correlation-and-causation-features/
21+
// - A stop event's event id must be next one after its start event.
2322

2423
[Event(1, Level = EventLevel.Informational)]
2524
public void HostStart()
@@ -33,69 +32,22 @@ public void HostStop()
3332
WriteEvent(2);
3433
}
3534

36-
[NonEvent]
37-
public void RequestStart(HttpContext context)
38-
{
39-
if (IsEnabled())
40-
{
41-
RequestStart(
42-
context.TraceIdentifier,
43-
context.Request.Protocol,
44-
context.Request.Method,
45-
context.Request.ContentType ?? string.Empty,
46-
context.Request.ContentLength.HasValue ? context.Request.ContentLength.Value.ToString() : string.Empty,
47-
context.Request.Scheme,
48-
context.Request.Host.Value,
49-
context.Request.PathBase,
50-
context.Request.Path,
51-
context.Request.QueryString.Value);
52-
}
53-
}
54-
55-
[NonEvent]
56-
public void RequestStop(HttpContext context, Exception exception = null)
35+
[Event(3, Level = EventLevel.Informational)]
36+
public void RequestStart(string method, string path)
5737
{
58-
if (IsEnabled())
59-
{
60-
RequestStop(
61-
context.Response.StatusCode,
62-
context.Response.ContentType ?? string.Empty,
63-
context.TraceIdentifier,
64-
exception == null ? string.Empty : exception.ToString());
65-
}
38+
WriteEvent(3, method, path);
6639
}
6740

68-
[Event(3, Level = EventLevel.Informational)]
69-
private void RequestStart(
70-
string requestTraceIdentifier,
71-
string protocol,
72-
string method,
73-
string contentType,
74-
string contentLength,
75-
string scheme,
76-
string host,
77-
string pathBase,
78-
string path,
79-
string queryString)
41+
[Event(4, Level = EventLevel.Informational)]
42+
public void RequestStop()
8043
{
81-
WriteEvent(
82-
3,
83-
requestTraceIdentifier,
84-
protocol,
85-
method,
86-
contentType,
87-
contentLength,
88-
scheme,
89-
host,
90-
pathBase,
91-
path,
92-
queryString);
44+
WriteEvent(4);
9345
}
9446

95-
[Event(4, Level = EventLevel.Informational)]
96-
private void RequestStop(int statusCode, string contentType, string requestTraceIdentifier, string exception)
47+
[Event(5, Level = EventLevel.Error)]
48+
public void UnhandledException()
9749
{
98-
WriteEvent(4, statusCode, contentType, requestTraceIdentifier, exception);
50+
WriteEvent(5);
9951
}
10052
}
10153
}

0 commit comments

Comments
 (0)