Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Add httpContext.TraceIdentifier and httpContext.Response.StatusCode k…
Browse files Browse the repository at this point in the history
…eywords which provide useful information for correlation.
  • Loading branch information
northtyphoon committed Feb 15, 2017
1 parent 1e77bb6 commit 0ebc7ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ public class Keywords
"httpContext.Request.Path;" +
"httpContext.Request.QueryString" +
"\n" +
"Microsoft.AspNetCore/Microsoft.AspNetCore.Hosting.EndRequest@Activity1Stop:-";
"Microsoft.AspNetCore/Microsoft.AspNetCore.Hosting.EndRequest@Activity1Stop:-" +
"httpContext.TraceIdentifier;" +
"httpContext.Response.StatusCode";

// Setting EntityFrameworkCoreCommands is like having this in the FilterAndPayloadSpecs string
// It turns on basic SQL commands.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,25 @@ public void TestShortcutKeywords()
eventSourceListener.ResetEventCountAndLastEvent();

// Stop the ASP.NET reqeust.
aspNetCoreSource.Write("Microsoft.AspNetCore.Hosting.EndRequest", null);
aspNetCoreSource.Write("Microsoft.AspNetCore.Hosting.EndRequest",
new
{
httpContext = new
{
Response = new
{
StatusCode = "200"
},
TraceIdentifier = "MyTraceId"
}
});
Assert.Equal(1, eventSourceListener.EventCount); // Exactly one more event has been emitted.
Assert.Equal("Activity1Stop", eventSourceListener.LastEvent.EventSourceEventName);
Assert.Equal("Microsoft.AspNetCore", eventSourceListener.LastEvent.SourceName);
Assert.Equal("Microsoft.AspNetCore.Hosting.EndRequest", eventSourceListener.LastEvent.EventName);
Assert.True(2 <= eventSourceListener.LastEvent.Arguments.Count);
Assert.Equal("MyTraceId", eventSourceListener.LastEvent.Arguments["TraceIdentifier"]);
Assert.Equal("200", eventSourceListener.LastEvent.Arguments["StatusCode"]);
eventSourceListener.ResetEventCountAndLastEvent();
}
}
Expand Down

0 comments on commit 0ebc7ad

Please sign in to comment.