{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/24847984","id":24847984,"diff_hunk":"@@ -0,0 +1,76 @@\n+package httpcontext\n+\n+import (\n+\t\"math/rand\"\n+\t\"net/http\"\n+\t\"strconv\"\n+\t\"sync\"\n+\n+\t\"github.com/golang/glog\"\n+\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/api\"\n+)\n+\n+const header = \"X-Trace\"\n+\n+var (\n+\tlock     sync.RWMutex\n+\trequests map[*http.Request]api.Context\n+)\n+\n+func init() {\n+\trequests = make(map[*http.Request]api.Context)\n+}\n+\n+func For(req *http.Request) api.Context {\n+\tlock.RLock()\n+\tdefer lock.RUnlock()\n+\tctx, ok := requests[req]","path":"pkg/api/httpcontext/httpcontext.go","position":28,"original_position":28,"commit_id":"ab044eeca1199f05385dd8613dd74c2fa7c28cc0","original_commit_id":"ab044eeca1199f05385dd8613dd74c2fa7c28cc0","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"body":"Ugh - that's a good point.  This was the gorilla pattern, but it breaks in our transport wrappers.\n\n----- Original Message -----\n> > +\n> > +const header = \"X-Trace\"\n> > +\n> > +var (\n> > +\tlock     sync.RWMutex\n> > +\trequests map[*http.Request]api.Context\n> > +)\n> > +\n> > +func init() {\n> > +\trequests = make(map[*http.Request]api.Context)\n> > +}\n> > +\n> > +func For(req *http.Request) api.Context {\n> > +\tlock.RLock()\n> > +\tdefer lock.RUnlock()\n> > +\tctx, ok := requests[req]\n> \n> Suggestion: instead of using a pointer as a key, actually modify the request,\n> adding an X-Trace header if one isn't found. Then make the map from X-Trace\n> to ctx instead of from pointer to ctx.\n> \n> Using pointers breaks as soon as someone copies a request... not that people\n> should do that, but it feels kinda bad.\n> \n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/GoogleCloudPlatform/kubernetes/pull/3826/files#r24847837\n","created_at":"2015-02-17T19:56:54Z","updated_at":"2015-02-17T19:56:54Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/3826#discussion_r24847984","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/3826","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/24847984"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/3826#discussion_r24847984"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/3826"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/3826","id":28082084,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/3826","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/3826.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/3826.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/3826","number":3826,"state":"open","locked":false,"title":"WIP - Add trace header for all incoming requests","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"body":"This is a very simple PoC for a trace header to attach to requests and\nmove them through the system. The end goal is to establish a unique\nidentifier for an incoming request and propogate it down through all\nlayers of the stack and out to other endpoints. I'm not aware of a\nlibrary in Go that does this automatically, so I've started with the\nbasic sketch:\n\n* Use google.Context (our api.Context object) to use or set a trace from the 'X-Trace' header as a top level http wrapper\n* Set a context map for api.Context for code that does not properly pass api.Context but has access to the request\n  * TODO: pass api.Context down through all of the api server methods\n* Reuse the latest context in rest handler rather than initializing a new one\n* Pass 'X-Trace' from RESTClient\n* TODO: others\n\nFeedback?","created_at":"2015-01-27T03:54:19Z","updated_at":"2015-02-17T19:56:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59c0800bd1653a84c287ec25d4c4bab377478c20","assignee":{"login":"davidopp","id":8264113,"avatar_url":"https://avatars.githubusercontent.com/u/8264113?v=3","gravatar_id":"","url":"https://api.github.com/users/davidopp","html_url":"https://github.com/davidopp","followers_url":"https://api.github.com/users/davidopp/followers","following_url":"https://api.github.com/users/davidopp/following{/other_user}","gists_url":"https://api.github.com/users/davidopp/gists{/gist_id}","starred_url":"https://api.github.com/users/davidopp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidopp/subscriptions","organizations_url":"https://api.github.com/users/davidopp/orgs","repos_url":"https://api.github.com/users/davidopp/repos","events_url":"https://api.github.com/users/davidopp/events{/privacy}","received_events_url":"https://api.github.com/users/davidopp/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/3826/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/3826/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/{number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/3826/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/ab044eeca1199f05385dd8613dd74c2fa7c28cc0","head":{"label":"smarterclayton:begin_adding_traceability","ref":"begin_adding_traceability","sha":"ab044eeca1199f05385dd8613dd74c2fa7c28cc0","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"repo":{"id":21225407,"name":"kubernetes","full_name":"smarterclayton/kubernetes","owner":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smarterclayton/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/smarterclayton/kubernetes","forks_url":"https://api.github.com/repos/smarterclayton/kubernetes/forks","keys_url":"https://api.github.com/repos/smarterclayton/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smarterclayton/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smarterclayton/kubernetes/teams","hooks_url":"https://api.github.com/repos/smarterclayton/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/smarterclayton/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/smarterclayton/kubernetes/events","assignees_url":"https://api.github.com/repos/smarterclayton/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/smarterclayton/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/smarterclayton/kubernetes/tags","blobs_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smarterclayton/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/smarterclayton/kubernetes/languages","stargazers_url":"https://api.github.com/repos/smarterclayton/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/smarterclayton/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/smarterclayton/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/smarterclayton/kubernetes/subscription","commits_url":"https://api.github.com/repos/smarterclayton/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/smarterclayton/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/smarterclayton/kubernetes/issues/comments/{number}","contents_url":"https://api.github.com/repos/smarterclayton/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/smarterclayton/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smarterclayton/kubernetes/merges","archive_url":"https://api.github.com/repos/smarterclayton/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smarterclayton/kubernetes/downloads","issues_url":"https://api.github.com/repos/smarterclayton/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/smarterclayton/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/smarterclayton/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/smarterclayton/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smarterclayton/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/smarterclayton/kubernetes/releases{/id}","created_at":"2014-06-26T02:28:13Z","updated_at":"2014-06-26T01:04:38Z","pushed_at":"2015-02-17T17:16:12Z","git_url":"git://github.com/smarterclayton/kubernetes.git","ssh_url":"git@github.com:smarterclayton/kubernetes.git","clone_url":"https://github.com/smarterclayton/kubernetes.git","svn_url":"https://github.com/smarterclayton/kubernetes","homepage":null,"size":30643,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"d78d3e69c3774f7b50bf197c546adcde6e52a8bd","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"GoogleCloudPlatform/kubernetes","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes","description":"Container Cluster Manager","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/comments/{number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-02-17T19:49:50Z","pushed_at":"2015-02-17T19:49:50Z","git_url":"git://github.com/GoogleCloudPlatform/kubernetes.git","ssh_url":"git@github.com:GoogleCloudPlatform/kubernetes.git","clone_url":"https://github.com/GoogleCloudPlatform/kubernetes.git","svn_url":"https://github.com/GoogleCloudPlatform/kubernetes","homepage":"http://kubernetes.io","size":79398,"stargazers_count":6253,"watchers_count":6253,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1096,"mirror_url":null,"open_issues_count":698,"forks":1096,"open_issues":698,"watchers":6253,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/3826"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/3826"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/3826"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/3826/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/3826/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/3826/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/ab044eeca1199f05385dd8613dd74c2fa7c28cc0"}}}}