1
1
// Copyright (c) .NET Foundation. All rights reserved.
2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
- using System ;
5
- using System . Linq ;
6
4
using System . Diagnostics . Tracing ;
7
5
using Microsoft . AspNetCore . Http ;
8
- using Microsoft . Net . Http . Headers ;
9
6
10
7
namespace Microsoft . AspNetCore . Hosting . Internal
11
8
{
@@ -16,10 +13,12 @@ public sealed class HostingEventSource : EventSource
16
13
17
14
private HostingEventSource ( ) { }
18
15
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.
23
22
24
23
[ Event ( 1 , Level = EventLevel . Informational ) ]
25
24
public void HostStart ( )
@@ -33,69 +32,22 @@ public void HostStop()
33
32
WriteEvent ( 2 ) ;
34
33
}
35
34
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 )
57
37
{
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 ) ;
66
39
}
67
40
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 ( )
80
43
{
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 ) ;
93
45
}
94
46
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 ( )
97
49
{
98
- WriteEvent ( 4 , statusCode , contentType , requestTraceIdentifier , exception ) ;
50
+ WriteEvent ( 5 ) ;
99
51
}
100
52
}
101
53
}
0 commit comments