{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Hosting/pulls/comments/41929339","id":41929339,"diff_hunk":"@@ -0,0 +1,135 @@\n+﻿// Copyright (c) .NET Foundation. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System;\n+using System.Collections.Generic;\n+using System.Threading;\n+using Microsoft.AspNet.Http;\n+using Microsoft.AspNet.Http.Features;\n+using Microsoft.Extensions.Logging;\n+\n+namespace Microsoft.AspNet.Hosting.Internal\n+{\n+    internal static class HostingLoggerExtensions\n+    {\n+        public static IDisposable RequestScope(this ILogger logger, HttpContext httpContext)\n+        {\n+            return logger.BeginScopeImpl(new HostingRequestScope(httpContext));\n+        }\n+\n+        public static void RequestStarting(this ILogger logger, HttpContext httpContext)\n+        {\n+            if (logger.IsEnabled(LogLevel.Information))\n+            {\n+                logger.Log(LogLevel.Information, 1, new HostingRequestStarting(httpContext), null, HostingRequestStarting.Callback);\n+            }\n+        }\n+\n+        public static void RequestFinished(this ILogger logger, HttpContext httpContext)\n+        {\n+            if (logger.IsEnabled(LogLevel.Information))\n+            {\n+                logger.Log(LogLevel.Information, 2, new HostingRequestFinished(httpContext), null, HostingRequestFinished.Callback);\n+            }\n+        }\n+\n+        private class HostingRequestScope : ILogValues\n+        {\n+            private readonly HttpContext _httpContext;\n+\n+            private FeatureReference<IHttpRequestIdentifierFeature> _requestIdentifierFeatureReference;\n+            private IEnumerable<KeyValuePair<string, object>> _cachedGetValues;\n+            private string _cachedToString;\n+\n+            public HostingRequestScope(HttpContext httpContext)\n+            {\n+                this._httpContext = httpContext;\n+            }\n+\n+            public IHttpRequestIdentifierFeature RequestIdFeature =>\n+                _requestIdentifierFeatureReference.Fetch(_httpContext.Features) ??\n+                _requestIdentifierFeatureReference.Update(_httpContext.Features, new FastHttpRequestIdentifierFeature());\n+\n+            public override string ToString() => _cachedToString ?? Interlocked.CompareExchange(\n+                ref _cachedToString,\n+                $\"RequestId:{RequestIdFeature.TraceIdentifier} RequestPath:{_httpContext.Request.Path}\",","path":"src/Microsoft.AspNet.Hosting/Internal/HostingLoggerExtensions.cs","position":55,"original_position":55,"commit_id":"7921894e57b29c9880bab14e763599eb5932be14","original_commit_id":"2796353fab30bcb61bc62db64b48ba8445f4b394","user":{"login":"Tratcher","id":1821173,"avatar_url":"https://avatars.githubusercontent.com/u/1821173?v=3","gravatar_id":"","url":"https://api.github.com/users/Tratcher","html_url":"https://github.com/Tratcher","followers_url":"https://api.github.com/users/Tratcher/followers","following_url":"https://api.github.com/users/Tratcher/following{/other_user}","gists_url":"https://api.github.com/users/Tratcher/gists{/gist_id}","starred_url":"https://api.github.com/users/Tratcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tratcher/subscriptions","organizations_url":"https://api.github.com/users/Tratcher/orgs","repos_url":"https://api.github.com/users/Tratcher/repos","events_url":"https://api.github.com/users/Tratcher/events{/privacy}","received_events_url":"https://api.github.com/users/Tratcher/received_events","type":"User","site_admin":false},"body":"Or, why bother providing any information at all?","created_at":"2015-10-13T21:38:48Z","updated_at":"2015-10-13T21:38:48Z","html_url":"https://github.com/aspnet/Hosting/pull/403#discussion_r41929339","pull_request_url":"https://api.github.com/repos/aspnet/Hosting/pulls/403","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Hosting/pulls/comments/41929339"},"html":{"href":"https://github.com/aspnet/Hosting/pull/403#discussion_r41929339"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Hosting/pulls/403"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Hosting/pulls/403","id":47589422,"html_url":"https://github.com/aspnet/Hosting/pull/403","diff_url":"https://github.com/aspnet/Hosting/pull/403.diff","patch_url":"https://github.com/aspnet/Hosting/pull/403.patch","issue_url":"https://api.github.com/repos/aspnet/Hosting/issues/403","number":403,"state":"open","locked":false,"title":"Reduce logging overhead in hosting","user":{"login":"lodejard","id":1693989,"avatar_url":"https://avatars.githubusercontent.com/u/1693989?v=3","gravatar_id":"","url":"https://api.github.com/users/lodejard","html_url":"https://github.com/lodejard","followers_url":"https://api.github.com/users/lodejard/followers","following_url":"https://api.github.com/users/lodejard/following{/other_user}","gists_url":"https://api.github.com/users/lodejard/gists{/gist_id}","starred_url":"https://api.github.com/users/lodejard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lodejard/subscriptions","organizations_url":"https://api.github.com/users/lodejard/orgs","repos_url":"https://api.github.com/users/lodejard/repos","events_url":"https://api.github.com/users/lodejard/events{/privacy}","received_events_url":"https://api.github.com/users/lodejard/received_events","type":"User","site_admin":false},"body":"* TraceIdentifier is done at the last moment, or not at all\r\n* Request starting and finished messages are added\r\n* This pair provide many of the top-level values that you would have\r\n  found in server log files.","created_at":"2015-10-13T21:13:52Z","updated_at":"2015-10-13T21:38:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12bcf21bf9ae401eb848bbb34c359430fe7f6f4e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Hosting/pulls/403/commits","review_comments_url":"https://api.github.com/repos/aspnet/Hosting/pulls/403/comments","review_comment_url":"https://api.github.com/repos/aspnet/Hosting/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Hosting/issues/403/comments","statuses_url":"https://api.github.com/repos/aspnet/Hosting/statuses/7921894e57b29c9880bab14e763599eb5932be14","head":{"label":"aspnet:lodejard/perf-logging","ref":"lodejard/perf-logging","sha":"7921894e57b29c9880bab14e763599eb5932be14","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":16630141,"name":"Hosting","full_name":"aspnet/Hosting","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Hosting","description":"Code for hosting and starting up an ASP.NET application.","fork":false,"url":"https://api.github.com/repos/aspnet/Hosting","forks_url":"https://api.github.com/repos/aspnet/Hosting/forks","keys_url":"https://api.github.com/repos/aspnet/Hosting/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Hosting/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Hosting/teams","hooks_url":"https://api.github.com/repos/aspnet/Hosting/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Hosting/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Hosting/events","assignees_url":"https://api.github.com/repos/aspnet/Hosting/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Hosting/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Hosting/tags","blobs_url":"https://api.github.com/repos/aspnet/Hosting/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Hosting/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Hosting/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Hosting/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Hosting/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Hosting/languages","stargazers_url":"https://api.github.com/repos/aspnet/Hosting/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Hosting/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Hosting/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Hosting/subscription","commits_url":"https://api.github.com/repos/aspnet/Hosting/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Hosting/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Hosting/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Hosting/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Hosting/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Hosting/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Hosting/merges","archive_url":"https://api.github.com/repos/aspnet/Hosting/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Hosting/downloads","issues_url":"https://api.github.com/repos/aspnet/Hosting/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Hosting/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Hosting/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Hosting/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Hosting/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Hosting/releases{/id}","created_at":"2014-02-07T22:58:12Z","updated_at":"2015-10-13T06:24:21Z","pushed_at":"2015-10-13T21:29:41Z","git_url":"git://github.com/aspnet/Hosting.git","ssh_url":"git@github.com:aspnet/Hosting.git","clone_url":"https://github.com/aspnet/Hosting.git","svn_url":"https://github.com/aspnet/Hosting","homepage":"","size":4051,"stargazers_count":135,"watchers_count":135,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":42,"forks":75,"open_issues":42,"watchers":135,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"374526b2704f6a6b1dbb6587b704efd29109ab30","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":16630141,"name":"Hosting","full_name":"aspnet/Hosting","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Hosting","description":"Code for hosting and starting up an ASP.NET application.","fork":false,"url":"https://api.github.com/repos/aspnet/Hosting","forks_url":"https://api.github.com/repos/aspnet/Hosting/forks","keys_url":"https://api.github.com/repos/aspnet/Hosting/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Hosting/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Hosting/teams","hooks_url":"https://api.github.com/repos/aspnet/Hosting/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Hosting/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Hosting/events","assignees_url":"https://api.github.com/repos/aspnet/Hosting/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Hosting/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Hosting/tags","blobs_url":"https://api.github.com/repos/aspnet/Hosting/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Hosting/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Hosting/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Hosting/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Hosting/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Hosting/languages","stargazers_url":"https://api.github.com/repos/aspnet/Hosting/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Hosting/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Hosting/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Hosting/subscription","commits_url":"https://api.github.com/repos/aspnet/Hosting/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Hosting/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Hosting/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Hosting/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Hosting/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Hosting/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Hosting/merges","archive_url":"https://api.github.com/repos/aspnet/Hosting/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Hosting/downloads","issues_url":"https://api.github.com/repos/aspnet/Hosting/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Hosting/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Hosting/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Hosting/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Hosting/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Hosting/releases{/id}","created_at":"2014-02-07T22:58:12Z","updated_at":"2015-10-13T06:24:21Z","pushed_at":"2015-10-13T21:29:41Z","git_url":"git://github.com/aspnet/Hosting.git","ssh_url":"git@github.com:aspnet/Hosting.git","clone_url":"https://github.com/aspnet/Hosting.git","svn_url":"https://github.com/aspnet/Hosting","homepage":"","size":4051,"stargazers_count":135,"watchers_count":135,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":42,"forks":75,"open_issues":42,"watchers":135,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Hosting/pulls/403"},"html":{"href":"https://github.com/aspnet/Hosting/pull/403"},"issue":{"href":"https://api.github.com/repos/aspnet/Hosting/issues/403"},"comments":{"href":"https://api.github.com/repos/aspnet/Hosting/issues/403/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Hosting/pulls/403/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Hosting/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Hosting/pulls/403/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Hosting/statuses/7921894e57b29c9880bab14e763599eb5932be14"}}}}