{"action":"created","comment":{"url":"https://api.github.com/repos/go-kit/kit/pulls/comments/62259889","id":62259889,"diff_hunk":"@@ -0,0 +1,56 @@\n+package opentracing\n+\n+import (\n+\t\"github.com/opentracing/opentracing-go\"\n+\t\"golang.org/x/net/context\"\n+\t\"google.golang.org/grpc/metadata\"\n+)\n+\n+// ToGRPCRequest returns a grpc RequestFunc that injects an OpenTracing Span\n+// found in `ctx` into the grpc Metadata. If no such Span can be found, the\n+// RequestFunc is a noop.\n+func ToGRPCRequest(tracer opentracing.Tracer) func(ctx context.Context, md *metadata.MD) context.Context {\n+\treturn func(ctx context.Context, md *metadata.MD) context.Context {\n+\t\tif span := opentracing.SpanFromContext(ctx); span != nil {\n+\t\t\t// There's nothing we can do with an error here.\n+\t\t\t_ = tracer.Inject(span, opentracing.TextMap, metadataReaderWriter{md})\n+\t\t}\n+\t\treturn ctx\n+\t}\n+}","path":"tracing/opentracing/grpc.go","position":20,"original_position":20,"commit_id":"479593c298608e32407496ffbf3c44d95dc93617","original_commit_id":"7b60fe7db7da305d677feca29de589c3ef93d932","user":{"login":"bensigelman","id":2251553,"avatar_url":"https://avatars.githubusercontent.com/u/2251553?v=3","gravatar_id":"","url":"https://api.github.com/users/bensigelman","html_url":"https://github.com/bensigelman","followers_url":"https://api.github.com/users/bensigelman/followers","following_url":"https://api.github.com/users/bensigelman/following{/other_user}","gists_url":"https://api.github.com/users/bensigelman/gists{/gist_id}","starred_url":"https://api.github.com/users/bensigelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bensigelman/subscriptions","organizations_url":"https://api.github.com/users/bensigelman/orgs","repos_url":"https://api.github.com/users/bensigelman/repos","events_url":"https://api.github.com/users/bensigelman/events{/privacy}","received_events_url":"https://api.github.com/users/bensigelman/received_events","type":"User","site_admin":false},"body":"@peterbourgon @basvanbeek one nice thing about OpenTracing is that it takes the \"Y\" out of your set-theory statement above... by defining how a given impl gets in and out of a string map and binary blob, OpenTracing instrumentation (that's tracer/\"X\"-agnostic) deals with the individual protocols.","created_at":"2016-05-05T21:38:48Z","updated_at":"2016-05-05T21:38:48Z","html_url":"https://github.com/go-kit/kit/pull/247#discussion_r62259889","pull_request_url":"https://api.github.com/repos/go-kit/kit/pulls/247","_links":{"self":{"href":"https://api.github.com/repos/go-kit/kit/pulls/comments/62259889"},"html":{"href":"https://github.com/go-kit/kit/pull/247#discussion_r62259889"},"pull_request":{"href":"https://api.github.com/repos/go-kit/kit/pulls/247"}}},"pull_request":{"url":"https://api.github.com/repos/go-kit/kit/pulls/247","id":68522351,"html_url":"https://github.com/go-kit/kit/pull/247","diff_url":"https://github.com/go-kit/kit/pull/247.diff","patch_url":"https://github.com/go-kit/kit/pull/247.patch","issue_url":"https://api.github.com/repos/go-kit/kit/issues/247","number":247,"state":"open","locked":false,"title":"RFC for OpenTracing integration","user":{"login":"bensigelman","id":2251553,"avatar_url":"https://avatars.githubusercontent.com/u/2251553?v=3","gravatar_id":"","url":"https://api.github.com/users/bensigelman","html_url":"https://github.com/bensigelman","followers_url":"https://api.github.com/users/bensigelman/followers","following_url":"https://api.github.com/users/bensigelman/following{/other_user}","gists_url":"https://api.github.com/users/bensigelman/gists{/gist_id}","starred_url":"https://api.github.com/users/bensigelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bensigelman/subscriptions","organizations_url":"https://api.github.com/users/bensigelman/orgs","repos_url":"https://api.github.com/users/bensigelman/repos","events_url":"https://api.github.com/users/bensigelman/events{/privacy}","received_events_url":"https://api.github.com/users/bensigelman/received_events","type":"User","site_admin":false},"body":"(See #237 for motivation and context)\r\n\r\n# \"Demo\" (sic)\r\nThe `addsvc` in this PR uses the generic OpenTracing bindings for the httpjson and grpc transports, and in its `main()` it binds to either Appdash or LightStep (both of which are trivial to set up and have implementations of the Go OpenTracing API). As such, without changing any of the actual instrumentation beyond the `main()` function, both Appdash and LightStep are able to trace addsvc:\r\n\r\n## Appdash\r\n\r\n```\r\n$ addsvc -appdash_hostport=localhost:7701 &\r\n$ client -transport=grpc -appdash_hostport=localhost:7701 concat open tracing\r\n```\r\n![image](https://cloud.githubusercontent.com/assets/2251553/14947320/20d30592-0fe6-11e6-9239-4db9172c2976.png)\r\n\r\n## LightStep\r\n\r\n```\r\n$ addsvc -lightstep_access_token=XXX &\r\n$ client -transport=grpc -lightstep_access_token=XXX concat open tracing\r\n```\r\n![image](https://cloud.githubusercontent.com/assets/2251553/14947339/80c04ee2-0fe6-11e6-9d5b-fe1fd2a9158a.png)\r\n\r\n# Misc notes\r\n\r\nThe default implementation of OpenTracing is a noop. As such, rather than forcing users to install these various pieces of middleware/etc, some of this instrumentation could be opt-out, or perhaps downright unavoidable. Again, if the programmer didn't bother binding to OpenTracing, there would be near-zero overhead to support the noop implementation.\r\n\r\nAlso, the existing Zipkin instrumentation is worth thinking through in more detail. There are major companies that have adopted OpenTracing and bound it to Zipkin internally, so we know it's possible to go that route. If there's interest, we could try to port the `tracing/zipkin` package to be a pure OpenTracing implementation. I don't know how many depend on its API already, though.\r\n\r\n# Next steps\r\n\r\nI'd like to get basic feedback about the direction. If there's enthusiasm, I can finish up the other transports, add real tests, and merge this in. If there are problems, I'd rather go through them now before finishing up all of the odds and ends.\r\n\r\n- - - - - - - - -\r\n\r\nThanks for reviewing!\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"35\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/go-kit/kit/247)\n<!-- Reviewable:end -->\n","created_at":"2016-05-02T04:55:11Z","updated_at":"2016-05-05T21:38:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d9eafdb78cfa21f5a82a260ff00a789412e834ee","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/go-kit/kit/pulls/247/commits","review_comments_url":"https://api.github.com/repos/go-kit/kit/pulls/247/comments","review_comment_url":"https://api.github.com/repos/go-kit/kit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/go-kit/kit/issues/247/comments","statuses_url":"https://api.github.com/repos/go-kit/kit/statuses/479593c298608e32407496ffbf3c44d95dc93617","head":{"label":"bensigelman:bhs/opentracing","ref":"bhs/opentracing","sha":"479593c298608e32407496ffbf3c44d95dc93617","user":{"login":"bensigelman","id":2251553,"avatar_url":"https://avatars.githubusercontent.com/u/2251553?v=3","gravatar_id":"","url":"https://api.github.com/users/bensigelman","html_url":"https://github.com/bensigelman","followers_url":"https://api.github.com/users/bensigelman/followers","following_url":"https://api.github.com/users/bensigelman/following{/other_user}","gists_url":"https://api.github.com/users/bensigelman/gists{/gist_id}","starred_url":"https://api.github.com/users/bensigelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bensigelman/subscriptions","organizations_url":"https://api.github.com/users/bensigelman/orgs","repos_url":"https://api.github.com/users/bensigelman/repos","events_url":"https://api.github.com/users/bensigelman/events{/privacy}","received_events_url":"https://api.github.com/users/bensigelman/received_events","type":"User","site_admin":false},"repo":{"id":57162718,"name":"kit","full_name":"bensigelman/kit","owner":{"login":"bensigelman","id":2251553,"avatar_url":"https://avatars.githubusercontent.com/u/2251553?v=3","gravatar_id":"","url":"https://api.github.com/users/bensigelman","html_url":"https://github.com/bensigelman","followers_url":"https://api.github.com/users/bensigelman/followers","following_url":"https://api.github.com/users/bensigelman/following{/other_user}","gists_url":"https://api.github.com/users/bensigelman/gists{/gist_id}","starred_url":"https://api.github.com/users/bensigelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bensigelman/subscriptions","organizations_url":"https://api.github.com/users/bensigelman/orgs","repos_url":"https://api.github.com/users/bensigelman/repos","events_url":"https://api.github.com/users/bensigelman/events{/privacy}","received_events_url":"https://api.github.com/users/bensigelman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bensigelman/kit","description":"A standard library for microservices.","fork":true,"url":"https://api.github.com/repos/bensigelman/kit","forks_url":"https://api.github.com/repos/bensigelman/kit/forks","keys_url":"https://api.github.com/repos/bensigelman/kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bensigelman/kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bensigelman/kit/teams","hooks_url":"https://api.github.com/repos/bensigelman/kit/hooks","issue_events_url":"https://api.github.com/repos/bensigelman/kit/issues/events{/number}","events_url":"https://api.github.com/repos/bensigelman/kit/events","assignees_url":"https://api.github.com/repos/bensigelman/kit/assignees{/user}","branches_url":"https://api.github.com/repos/bensigelman/kit/branches{/branch}","tags_url":"https://api.github.com/repos/bensigelman/kit/tags","blobs_url":"https://api.github.com/repos/bensigelman/kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bensigelman/kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bensigelman/kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/bensigelman/kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bensigelman/kit/statuses/{sha}","languages_url":"https://api.github.com/repos/bensigelman/kit/languages","stargazers_url":"https://api.github.com/repos/bensigelman/kit/stargazers","contributors_url":"https://api.github.com/repos/bensigelman/kit/contributors","subscribers_url":"https://api.github.com/repos/bensigelman/kit/subscribers","subscription_url":"https://api.github.com/repos/bensigelman/kit/subscription","commits_url":"https://api.github.com/repos/bensigelman/kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/bensigelman/kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/bensigelman/kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/bensigelman/kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/bensigelman/kit/contents/{+path}","compare_url":"https://api.github.com/repos/bensigelman/kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bensigelman/kit/merges","archive_url":"https://api.github.com/repos/bensigelman/kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bensigelman/kit/downloads","issues_url":"https://api.github.com/repos/bensigelman/kit/issues{/number}","pulls_url":"https://api.github.com/repos/bensigelman/kit/pulls{/number}","milestones_url":"https://api.github.com/repos/bensigelman/kit/milestones{/number}","notifications_url":"https://api.github.com/repos/bensigelman/kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bensigelman/kit/labels{/name}","releases_url":"https://api.github.com/repos/bensigelman/kit/releases{/id}","deployments_url":"https://api.github.com/repos/bensigelman/kit/deployments","created_at":"2016-04-26T21:21:46Z","updated_at":"2016-04-26T21:21:47Z","pushed_at":"2016-05-05T21:27:06Z","git_url":"git://github.com/bensigelman/kit.git","ssh_url":"git@github.com:bensigelman/kit.git","clone_url":"https://github.com/bensigelman/kit.git","svn_url":"https://github.com/bensigelman/kit","homepage":"http://gokit.io","size":4696,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"go-kit:master","ref":"master","sha":"60b4d800f541554ebca34ea77265e574b2ca79a9","user":{"login":"go-kit","id":10981023,"avatar_url":"https://avatars.githubusercontent.com/u/10981023?v=3","gravatar_id":"","url":"https://api.github.com/users/go-kit","html_url":"https://github.com/go-kit","followers_url":"https://api.github.com/users/go-kit/followers","following_url":"https://api.github.com/users/go-kit/following{/other_user}","gists_url":"https://api.github.com/users/go-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/go-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-kit/subscriptions","organizations_url":"https://api.github.com/users/go-kit/orgs","repos_url":"https://api.github.com/users/go-kit/repos","events_url":"https://api.github.com/users/go-kit/events{/privacy}","received_events_url":"https://api.github.com/users/go-kit/received_events","type":"Organization","site_admin":false},"repo":{"id":30215630,"name":"kit","full_name":"go-kit/kit","owner":{"login":"go-kit","id":10981023,"avatar_url":"https://avatars.githubusercontent.com/u/10981023?v=3","gravatar_id":"","url":"https://api.github.com/users/go-kit","html_url":"https://github.com/go-kit","followers_url":"https://api.github.com/users/go-kit/followers","following_url":"https://api.github.com/users/go-kit/following{/other_user}","gists_url":"https://api.github.com/users/go-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/go-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-kit/subscriptions","organizations_url":"https://api.github.com/users/go-kit/orgs","repos_url":"https://api.github.com/users/go-kit/repos","events_url":"https://api.github.com/users/go-kit/events{/privacy}","received_events_url":"https://api.github.com/users/go-kit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/go-kit/kit","description":"A standard library for microservices.","fork":false,"url":"https://api.github.com/repos/go-kit/kit","forks_url":"https://api.github.com/repos/go-kit/kit/forks","keys_url":"https://api.github.com/repos/go-kit/kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/go-kit/kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/go-kit/kit/teams","hooks_url":"https://api.github.com/repos/go-kit/kit/hooks","issue_events_url":"https://api.github.com/repos/go-kit/kit/issues/events{/number}","events_url":"https://api.github.com/repos/go-kit/kit/events","assignees_url":"https://api.github.com/repos/go-kit/kit/assignees{/user}","branches_url":"https://api.github.com/repos/go-kit/kit/branches{/branch}","tags_url":"https://api.github.com/repos/go-kit/kit/tags","blobs_url":"https://api.github.com/repos/go-kit/kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/go-kit/kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/go-kit/kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/go-kit/kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/go-kit/kit/statuses/{sha}","languages_url":"https://api.github.com/repos/go-kit/kit/languages","stargazers_url":"https://api.github.com/repos/go-kit/kit/stargazers","contributors_url":"https://api.github.com/repos/go-kit/kit/contributors","subscribers_url":"https://api.github.com/repos/go-kit/kit/subscribers","subscription_url":"https://api.github.com/repos/go-kit/kit/subscription","commits_url":"https://api.github.com/repos/go-kit/kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/go-kit/kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/go-kit/kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/go-kit/kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/go-kit/kit/contents/{+path}","compare_url":"https://api.github.com/repos/go-kit/kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/go-kit/kit/merges","archive_url":"https://api.github.com/repos/go-kit/kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/go-kit/kit/downloads","issues_url":"https://api.github.com/repos/go-kit/kit/issues{/number}","pulls_url":"https://api.github.com/repos/go-kit/kit/pulls{/number}","milestones_url":"https://api.github.com/repos/go-kit/kit/milestones{/number}","notifications_url":"https://api.github.com/repos/go-kit/kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/go-kit/kit/labels{/name}","releases_url":"https://api.github.com/repos/go-kit/kit/releases{/id}","deployments_url":"https://api.github.com/repos/go-kit/kit/deployments","created_at":"2015-02-03T00:01:19Z","updated_at":"2016-05-05T18:39:35Z","pushed_at":"2016-05-05T21:27:07Z","git_url":"git://github.com/go-kit/kit.git","ssh_url":"git@github.com:go-kit/kit.git","clone_url":"https://github.com/go-kit/kit.git","svn_url":"https://github.com/go-kit/kit","homepage":"http://gokit.io","size":7840,"stargazers_count":4154,"watchers_count":4154,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":315,"mirror_url":null,"open_issues_count":21,"forks":315,"open_issues":21,"watchers":4154,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/go-kit/kit/pulls/247"},"html":{"href":"https://github.com/go-kit/kit/pull/247"},"issue":{"href":"https://api.github.com/repos/go-kit/kit/issues/247"},"comments":{"href":"https://api.github.com/repos/go-kit/kit/issues/247/comments"},"review_comments":{"href":"https://api.github.com/repos/go-kit/kit/pulls/247/comments"},"review_comment":{"href":"https://api.github.com/repos/go-kit/kit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/go-kit/kit/pulls/247/commits"},"statuses":{"href":"https://api.github.com/repos/go-kit/kit/statuses/479593c298608e32407496ffbf3c44d95dc93617"}}}}