{"action":"created","comment":{"url":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/comments/50607718","id":50607718,"diff_hunk":"@@ -0,0 +1,150 @@\n+---\n+layout: page\n+title: Instrumentation for Common Use Cases\n+---\n+<div id=\"toc\"></div>\n+\n+This page aims to illustrate the common use cases that developers who instrument their applications with OpenTracing API need to deal with.\n+\n+### Tracing Server Endpoints\n+\n+When a server wants to trace execution of a request, it generally needs to go through these steps:\n+\n+  1. Attempt to deserialize Trace Context from the incoming request, in case the trace has already been started by the client.\n+  1. Depending on the outcome, either start a new trace, or join the existing trace using deserialized Trace Context. This operation starts a new Span.\n+  1. Store the newly created span in some _request context_ that is propagated throughout the application, either by application code, or by the RPC framework.\n+  1. Finally, close the span using `span.finish()` when the server has finished processing the request.\n+\n+#### Deserializing Trace Conext from Incoming Request\n+\n+Let's assume that we have an HTTP server, and the Trace Context is propagated from the client via HTTP headers, accessible via `request.headers`:\n+\n+```python\n+    context = tracer.trace_context_from_text(\n+        trace_context_id=request.headers,","path":"use-cases.md","position":24,"original_position":24,"commit_id":"6945fd97a97f1624ce8042a67bc2d534184bffb4","original_commit_id":"6945fd97a97f1624ce8042a67bc2d534184bffb4","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":"maybe add a comment that the maps passed to `trace_context_from_text` can be a superset of the fields that are required (hence passing the same headers in twice).","created_at":"2016-01-23T00:04:54Z","updated_at":"2016-01-23T00:04:54Z","html_url":"https://github.com/opentracing/opentracing.github.io/pull/34#discussion_r50607718","pull_request_url":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/comments/50607718"},"html":{"href":"https://github.com/opentracing/opentracing.github.io/pull/34#discussion_r50607718"},"pull_request":{"href":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/34","id":56945488,"html_url":"https://github.com/opentracing/opentracing.github.io/pull/34","diff_url":"https://github.com/opentracing/opentracing.github.io/pull/34.diff","patch_url":"https://github.com/opentracing/opentracing.github.io/pull/34.patch","issue_url":"https://api.github.com/repos/opentracing/opentracing.github.io/issues/34","number":34,"state":"open","locked":false,"title":"Add a page illustrating common instrumentation use cases","user":{"login":"yurishkuro","id":3523016,"avatar_url":"https://avatars.githubusercontent.com/u/3523016?v=3","gravatar_id":"","url":"https://api.github.com/users/yurishkuro","html_url":"https://github.com/yurishkuro","followers_url":"https://api.github.com/users/yurishkuro/followers","following_url":"https://api.github.com/users/yurishkuro/following{/other_user}","gists_url":"https://api.github.com/users/yurishkuro/gists{/gist_id}","starred_url":"https://api.github.com/users/yurishkuro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yurishkuro/subscriptions","organizations_url":"https://api.github.com/users/yurishkuro/orgs","repos_url":"https://api.github.com/users/yurishkuro/repos","events_url":"https://api.github.com/users/yurishkuro/events{/privacy}","received_events_url":"https://api.github.com/users/yurishkuro/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-22T21:41:56Z","updated_at":"2016-01-23T00:04:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f914869713eb3c832f97a6690eb548eadff88faf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/34/commits","review_comments_url":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/34/comments","review_comment_url":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opentracing/opentracing.github.io/issues/34/comments","statuses_url":"https://api.github.com/repos/opentracing/opentracing.github.io/statuses/6945fd97a97f1624ce8042a67bc2d534184bffb4","head":{"label":"opentracing:use-cases","ref":"use-cases","sha":"6945fd97a97f1624ce8042a67bc2d534184bffb4","user":{"login":"opentracing","id":15482765,"avatar_url":"https://avatars.githubusercontent.com/u/15482765?v=3","gravatar_id":"","url":"https://api.github.com/users/opentracing","html_url":"https://github.com/opentracing","followers_url":"https://api.github.com/users/opentracing/followers","following_url":"https://api.github.com/users/opentracing/following{/other_user}","gists_url":"https://api.github.com/users/opentracing/gists{/gist_id}","starred_url":"https://api.github.com/users/opentracing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opentracing/subscriptions","organizations_url":"https://api.github.com/users/opentracing/orgs","repos_url":"https://api.github.com/users/opentracing/repos","events_url":"https://api.github.com/users/opentracing/events{/privacy}","received_events_url":"https://api.github.com/users/opentracing/received_events","type":"Organization","site_admin":false},"repo":{"id":48717396,"name":"opentracing.github.io","full_name":"opentracing/opentracing.github.io","owner":{"login":"opentracing","id":15482765,"avatar_url":"https://avatars.githubusercontent.com/u/15482765?v=3","gravatar_id":"","url":"https://api.github.com/users/opentracing","html_url":"https://github.com/opentracing","followers_url":"https://api.github.com/users/opentracing/followers","following_url":"https://api.github.com/users/opentracing/following{/other_user}","gists_url":"https://api.github.com/users/opentracing/gists{/gist_id}","starred_url":"https://api.github.com/users/opentracing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opentracing/subscriptions","organizations_url":"https://api.github.com/users/opentracing/orgs","repos_url":"https://api.github.com/users/opentracing/repos","events_url":"https://api.github.com/users/opentracing/events{/privacy}","received_events_url":"https://api.github.com/users/opentracing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opentracing/opentracing.github.io","description":"Source code for http://opentracing.io","fork":false,"url":"https://api.github.com/repos/opentracing/opentracing.github.io","forks_url":"https://api.github.com/repos/opentracing/opentracing.github.io/forks","keys_url":"https://api.github.com/repos/opentracing/opentracing.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opentracing/opentracing.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opentracing/opentracing.github.io/teams","hooks_url":"https://api.github.com/repos/opentracing/opentracing.github.io/hooks","issue_events_url":"https://api.github.com/repos/opentracing/opentracing.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/opentracing/opentracing.github.io/events","assignees_url":"https://api.github.com/repos/opentracing/opentracing.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/opentracing/opentracing.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/opentracing/opentracing.github.io/tags","blobs_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opentracing/opentracing.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/opentracing/opentracing.github.io/languages","stargazers_url":"https://api.github.com/repos/opentracing/opentracing.github.io/stargazers","contributors_url":"https://api.github.com/repos/opentracing/opentracing.github.io/contributors","subscribers_url":"https://api.github.com/repos/opentracing/opentracing.github.io/subscribers","subscription_url":"https://api.github.com/repos/opentracing/opentracing.github.io/subscription","commits_url":"https://api.github.com/repos/opentracing/opentracing.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/opentracing/opentracing.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/opentracing/opentracing.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/opentracing/opentracing.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/opentracing/opentracing.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opentracing/opentracing.github.io/merges","archive_url":"https://api.github.com/repos/opentracing/opentracing.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opentracing/opentracing.github.io/downloads","issues_url":"https://api.github.com/repos/opentracing/opentracing.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/opentracing/opentracing.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/opentracing/opentracing.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opentracing/opentracing.github.io/labels{/name}","releases_url":"https://api.github.com/repos/opentracing/opentracing.github.io/releases{/id}","deployments_url":"https://api.github.com/repos/opentracing/opentracing.github.io/deployments","created_at":"2015-12-28T23:37:19Z","updated_at":"2016-01-17T00:04:17Z","pushed_at":"2016-01-22T22:39:34Z","git_url":"git://github.com/opentracing/opentracing.github.io.git","ssh_url":"git@github.com:opentracing/opentracing.github.io.git","clone_url":"https://github.com/opentracing/opentracing.github.io.git","svn_url":"https://github.com/opentracing/opentracing.github.io","homepage":"","size":67,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":15,"forks":2,"open_issues":15,"watchers":0,"default_branch":"master"}},"base":{"label":"opentracing:master","ref":"master","sha":"e3e298b20332a9fc73d1057d15f65e65efff5534","user":{"login":"opentracing","id":15482765,"avatar_url":"https://avatars.githubusercontent.com/u/15482765?v=3","gravatar_id":"","url":"https://api.github.com/users/opentracing","html_url":"https://github.com/opentracing","followers_url":"https://api.github.com/users/opentracing/followers","following_url":"https://api.github.com/users/opentracing/following{/other_user}","gists_url":"https://api.github.com/users/opentracing/gists{/gist_id}","starred_url":"https://api.github.com/users/opentracing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opentracing/subscriptions","organizations_url":"https://api.github.com/users/opentracing/orgs","repos_url":"https://api.github.com/users/opentracing/repos","events_url":"https://api.github.com/users/opentracing/events{/privacy}","received_events_url":"https://api.github.com/users/opentracing/received_events","type":"Organization","site_admin":false},"repo":{"id":48717396,"name":"opentracing.github.io","full_name":"opentracing/opentracing.github.io","owner":{"login":"opentracing","id":15482765,"avatar_url":"https://avatars.githubusercontent.com/u/15482765?v=3","gravatar_id":"","url":"https://api.github.com/users/opentracing","html_url":"https://github.com/opentracing","followers_url":"https://api.github.com/users/opentracing/followers","following_url":"https://api.github.com/users/opentracing/following{/other_user}","gists_url":"https://api.github.com/users/opentracing/gists{/gist_id}","starred_url":"https://api.github.com/users/opentracing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opentracing/subscriptions","organizations_url":"https://api.github.com/users/opentracing/orgs","repos_url":"https://api.github.com/users/opentracing/repos","events_url":"https://api.github.com/users/opentracing/events{/privacy}","received_events_url":"https://api.github.com/users/opentracing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opentracing/opentracing.github.io","description":"Source code for http://opentracing.io","fork":false,"url":"https://api.github.com/repos/opentracing/opentracing.github.io","forks_url":"https://api.github.com/repos/opentracing/opentracing.github.io/forks","keys_url":"https://api.github.com/repos/opentracing/opentracing.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opentracing/opentracing.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opentracing/opentracing.github.io/teams","hooks_url":"https://api.github.com/repos/opentracing/opentracing.github.io/hooks","issue_events_url":"https://api.github.com/repos/opentracing/opentracing.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/opentracing/opentracing.github.io/events","assignees_url":"https://api.github.com/repos/opentracing/opentracing.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/opentracing/opentracing.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/opentracing/opentracing.github.io/tags","blobs_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opentracing/opentracing.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/opentracing/opentracing.github.io/languages","stargazers_url":"https://api.github.com/repos/opentracing/opentracing.github.io/stargazers","contributors_url":"https://api.github.com/repos/opentracing/opentracing.github.io/contributors","subscribers_url":"https://api.github.com/repos/opentracing/opentracing.github.io/subscribers","subscription_url":"https://api.github.com/repos/opentracing/opentracing.github.io/subscription","commits_url":"https://api.github.com/repos/opentracing/opentracing.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/opentracing/opentracing.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/opentracing/opentracing.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/opentracing/opentracing.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/opentracing/opentracing.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/opentracing/opentracing.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opentracing/opentracing.github.io/merges","archive_url":"https://api.github.com/repos/opentracing/opentracing.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opentracing/opentracing.github.io/downloads","issues_url":"https://api.github.com/repos/opentracing/opentracing.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/opentracing/opentracing.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/opentracing/opentracing.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opentracing/opentracing.github.io/labels{/name}","releases_url":"https://api.github.com/repos/opentracing/opentracing.github.io/releases{/id}","deployments_url":"https://api.github.com/repos/opentracing/opentracing.github.io/deployments","created_at":"2015-12-28T23:37:19Z","updated_at":"2016-01-17T00:04:17Z","pushed_at":"2016-01-22T22:39:34Z","git_url":"git://github.com/opentracing/opentracing.github.io.git","ssh_url":"git@github.com:opentracing/opentracing.github.io.git","clone_url":"https://github.com/opentracing/opentracing.github.io.git","svn_url":"https://github.com/opentracing/opentracing.github.io","homepage":"","size":67,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":15,"forks":2,"open_issues":15,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/34"},"html":{"href":"https://github.com/opentracing/opentracing.github.io/pull/34"},"issue":{"href":"https://api.github.com/repos/opentracing/opentracing.github.io/issues/34"},"comments":{"href":"https://api.github.com/repos/opentracing/opentracing.github.io/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opentracing/opentracing.github.io/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/opentracing/opentracing.github.io/statuses/6945fd97a97f1624ce8042a67bc2d534184bffb4"}}}}