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

[Proposal] Lazy requestId and move TraceIdentifier to HttpAbstractions #394

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

15 changes: 1 addition & 14 deletions src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public virtual IApplication Start()
{
var httpContext = contextFactory.CreateHttpContext(features);
httpContext.ApplicationServices = _applicationServices;
var requestIdentifier = GetRequestIdentifier(httpContext);
contextAccessor.HttpContext = httpContext;
#pragma warning disable 0618
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.BeginRequest"))
Expand All @@ -107,7 +106,7 @@ public virtual IApplication Start()
try
{
using (logger.IsEnabled(LogLevel.Critical)
? logger.BeginScope("Request Id: {RequestId}", requestIdentifier)
? logger.BeginScope("Request Id: {RequestId}", httpContext.TraceIdentifier)
: null)
{
await application(httpContext);
Expand Down Expand Up @@ -276,18 +275,6 @@ private void EnsureServer()
}
}

private string GetRequestIdentifier(HttpContext httpContext)
{
var requestIdentifierFeature = httpContext.Features.Get<IHttpRequestIdentifierFeature>();
if (requestIdentifierFeature == null)
{
requestIdentifierFeature = new FastHttpRequestIdentifierFeature();
httpContext.Features.Set(requestIdentifierFeature);
}

return requestIdentifierFeature.TraceIdentifier;
}

private class Disposable : IDisposable
{
private Action _dispose;
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.AspNet.Hosting/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"url": "git://github.com/aspnet/hosting"
},
"compilationOptions": {
"warningsAsErrors": true,
"allowUnsafe": true
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.FileProviders.Physical": "1.0.0-*",
Expand Down
8 changes: 7 additions & 1 deletion test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,13 @@ public void HostingEngine_CreatesDefaultRequestIdentifierFeature_IfNotPresent()

// Assert
Assert.NotNull(httpContext);
Assert.IsType<FastHttpRequestIdentifierFeature>(httpContext.Features.Get<IHttpRequestIdentifierFeature>());
Assert.Null(httpContext.Features.Get<IHttpRequestIdentifierFeature>());

Assert.NotNull(httpContext.TraceIdentifier);
Assert.NotNull(httpContext.Features.Get<IHttpRequestIdentifierFeature>());
Assert.IsType<HttpRequestIdentifierFeature>(httpContext.Features.Get<IHttpRequestIdentifierFeature>());

Assert.Same(httpContext.TraceIdentifier, httpContext.Features.Get<IHttpRequestIdentifierFeature>().TraceIdentifier);
}

[Fact]
Expand Down

This file was deleted.