|
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
3 | 3 |
|
4 | 4 | using System.Diagnostics.Tracing;
|
5 |
| -using Microsoft.AspNetCore.Http; |
6 | 5 |
|
7 | 6 | namespace Microsoft.AspNetCore.Hosting.Internal
|
8 | 7 | {
|
@@ -53,56 +52,37 @@ public void RequestStart(string method, string path)
|
53 | 52 | #if NETSTANDARD1_5
|
54 | 53 | _requestCounter.WriteMetric(1);
|
55 | 54 | #endif
|
56 |
| - if (IsEnabled()) |
57 |
| - { |
58 |
| - RequestStart( |
59 |
| - context.TraceIdentifier, |
60 |
| - context.Request.Protocol, |
61 |
| - context.Request.Method, |
62 |
| - context.Request.ContentType ?? string.Empty, |
63 |
| - context.Request.ContentLength.HasValue ? context.Request.ContentLength.Value.ToString() : string.Empty, |
64 |
| - context.Request.Scheme, |
65 |
| - context.Request.Host.ToString(), |
66 |
| - context.Request.PathBase, |
67 |
| - context.Request.Path, |
68 |
| - context.Request.QueryString.ToString()); |
69 |
| - } |
70 | 55 | WriteEvent(3, method, path);
|
71 | 56 | }
|
72 | 57 |
|
73 |
| - [Event(4, Level = EventLevel.Informational)] |
74 |
| - public void RequestStop() |
| 58 | + [NonEvent] |
| 59 | + public void RequestStop(long startTimestamp, long endTimestamp) |
75 | 60 | {
|
76 | 61 | #if NETSTANDARD1_5
|
77 |
| - if (exception == null) |
78 |
| - { |
79 |
| - _successfulRequestCounter.WriteMetric(1); |
80 |
| - } |
81 |
| - else |
82 |
| - { |
83 |
| - _failedRequestCounter.WriteMetric(1); |
84 |
| - } |
| 62 | + _successfulRequestCounter.WriteMetric(1); |
85 | 63 |
|
86 | 64 | if (endTimestamp != 0)
|
87 | 65 | {
|
88 | 66 | _requestExecutionTimeCounter.WriteMetric(endTimestamp - startTimestamp);
|
89 | 67 | }
|
90 | 68 | #endif
|
91 |
| - if (IsEnabled()) |
92 |
| - { |
93 |
| - RequestStop( |
94 |
| - context.Response.StatusCode, |
95 |
| - context.Response.ContentType ?? string.Empty, |
96 |
| - context.TraceIdentifier, |
97 |
| - exception == null ? string.Empty : exception.ToString()); |
98 |
| - } |
| 69 | + RequestStop(); |
| 70 | + } |
| 71 | + |
| 72 | + [Event(4, Level = EventLevel.Informational)] |
| 73 | + private void RequestStop() |
| 74 | + { |
99 | 75 | WriteEvent(4);
|
100 | 76 | }
|
101 | 77 |
|
102 | 78 | [Event(5, Level = EventLevel.Error)]
|
103 | 79 | public void UnhandledException()
|
104 | 80 | {
|
| 81 | +#if NETSTANDARD1_5 |
| 82 | + _failedRequestCounter.WriteMetric(1); |
| 83 | +#endif |
105 | 84 | WriteEvent(5);
|
106 | 85 | }
|
| 86 | + |
107 | 87 | }
|
108 | 88 | }
|
0 commit comments