{"action":"created","comment":{"url":"https://api.github.com/repos/spandex-project/spandex/pulls/comments/222866311","pull_request_review_id":161858754,"id":222866311,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMjg2NjMxMQ==","diff_hunk":"@@ -0,0 +1,85 @@\n+if Code.ensure_loaded?(Decorator.Define) do\n+  defmodule Spandex.Decorators do\n+    @moduledoc \"\"\"\n+\n+    Span function decorators take an optional argument which is the attributes to update the span with. One of those attributes can be the `:tracer` in case you want to override the default tracer (e.g., in case you want to use multiple tracers).\n+\n+    IMPORTANT If you define multiple clauses for a function, you'll have to decorate all of the ones you want to span.\n+\n+    Note: Decorators don't magically do everything. It often makes a lot of sense to use `Tracer.update_span` from within your function to add details that are only available inside that same function.\n+\n+        defmodule Foo do\n+          use Spandex.Decorators\n+\n+          @decorate trace()\n+          def bar(a) do\n+            a * 2\n+          end\n+\n+          @decorate trace(service: \"ecto\", type: \"sql\")\n+          def databaz(a) do\n+            a * 3\n+          end\n+        end\n+    \"\"\"\n+\n+    @tracer Application.get_env(:spandex, :decorators)[:tracer]\n+    def __tracer__(), do: @tracer\n+\n+    use Decorator.Define, span: 0, span: 1, trace: 0, trace: 1\n+\n+    def trace(body, context) do\n+      trace([], body, context)\n+    end\n+\n+    def trace(attributes, body, context) do\n+      name =\n+        __MODULE__.span_name(\n+          attributes,\n+          context.module,\n+          context.name,\n+          context.arity\n+        )\n+\n+      tracer = attributes[:tracer] || unquote(__MODULE__).__tracer__()\n+      attributes = Keyword.delete(attributes, :tracer)\n+\n+      quote do\n+        require unquote(tracer)","path":"lib/decorators.ex","position":48,"original_position":48,"commit_id":"b5a0ed1626543bfc170d063b8c6c1b46ed2638e7","original_commit_id":"b5a0ed1626543bfc170d063b8c6c1b46ed2638e7","user":{"login":"zachdaniel","id":5722339,"node_id":"MDQ6VXNlcjU3MjIzMzk=","avatar_url":"https://avatars1.githubusercontent.com/u/5722339?v=4","gravatar_id":"","url":"https://api.github.com/users/zachdaniel","html_url":"https://github.com/zachdaniel","followers_url":"https://api.github.com/users/zachdaniel/followers","following_url":"https://api.github.com/users/zachdaniel/following{/other_user}","gists_url":"https://api.github.com/users/zachdaniel/gists{/gist_id}","starred_url":"https://api.github.com/users/zachdaniel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zachdaniel/subscriptions","organizations_url":"https://api.github.com/users/zachdaniel/orgs","repos_url":"https://api.github.com/users/zachdaniel/repos","events_url":"https://api.github.com/users/zachdaniel/events{/privacy}","received_events_url":"https://api.github.com/users/zachdaniel/received_events","type":"User","site_admin":false},"body":"`require` isn’t a runtime concept IIRC. It’s fine to require in any scope.","created_at":"2018-10-05T00:41:30Z","updated_at":"2018-10-05T00:41:30Z","html_url":"https://github.com/spandex-project/spandex/pull/80#discussion_r222866311","pull_request_url":"https://api.github.com/repos/spandex-project/spandex/pulls/80","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/spandex-project/spandex/pulls/comments/222866311"},"html":{"href":"https://github.com/spandex-project/spandex/pull/80#discussion_r222866311"},"pull_request":{"href":"https://api.github.com/repos/spandex-project/spandex/pulls/80"}},"in_reply_to_id":222864501},"pull_request":{"url":"https://api.github.com/repos/spandex-project/spandex/pulls/80","id":217452787,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3NDUyNzg3","html_url":"https://github.com/spandex-project/spandex/pull/80","diff_url":"https://github.com/spandex-project/spandex/pull/80.diff","patch_url":"https://github.com/spandex-project/spandex/pull/80.patch","issue_url":"https://api.github.com/repos/spandex-project/spandex/issues/80","number":80,"state":"open","locked":false,"title":"Bring back Spandex.TraceDecorator","user":{"login":"dnlserrano","id":5096953,"node_id":"MDQ6VXNlcjUwOTY5NTM=","avatar_url":"https://avatars1.githubusercontent.com/u/5096953?v=4","gravatar_id":"","url":"https://api.github.com/users/dnlserrano","html_url":"https://github.com/dnlserrano","followers_url":"https://api.github.com/users/dnlserrano/followers","following_url":"https://api.github.com/users/dnlserrano/following{/other_user}","gists_url":"https://api.github.com/users/dnlserrano/gists{/gist_id}","starred_url":"https://api.github.com/users/dnlserrano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnlserrano/subscriptions","organizations_url":"https://api.github.com/users/dnlserrano/orgs","repos_url":"https://api.github.com/users/dnlserrano/repos","events_url":"https://api.github.com/users/dnlserrano/events{/privacy}","received_events_url":"https://api.github.com/users/dnlserrano/received_events","type":"User","site_admin":false},"body":"This is a preliminary version of what we discussed over at the `#spandex` channel in the `elixir-lang` Slack.\r\n\r\nIt basically is a resurrection of what @zachdaniel had implemented (and deprecated) in the past using the [`decorator`](https://github.com/arjan/decorator) library. Me, @dcaixinha and @amalbuquerque were looking into this in a mob-programming fashion (❤️💚💛💙💜) and found some problems with it. Maybe it'd be nice to have the lib decorate stuff without the aid of the `decorator` library (although we still find it very useful!!), simply because it injects a `__using__` and that has the disadvantage of not allowing any other `__using__` statements to be defined in the context of whoever `use`s `Spandex.TraceDecorator`.\r\n\r\nAnyway, I think this is a good starting point that helped us in migrating from `1.3.3` to `2.3.0`. 😄 \r\n\r\nI'd love to hear your thoughts on some things in particular:\r\n\r\n- documentation\r\n- comments\r\n- `config :spandex, :decorators, tracer: MyApp.Tracer`\r\n- conditional compilation of `Spandex.TraceDecorator`\r\n\r\nI think this last one should be done before merging, I can help once I get back and have some feedback from you guys. I was looking at `mix`'s `elixirc_paths`, but I don't see an elegant way of excluding `lib/spandex/trace_decorator.ex`. I'll dig deeper.\r\n\r\n/cc @zachdaniel @GregMefford ","created_at":"2018-09-22T11:25:59Z","updated_at":"2018-10-05T00:41:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c67d31ccd12071d2284b1eb5eb80fbdce1c9a5f3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/spandex-project/spandex/pulls/80/commits","review_comments_url":"https://api.github.com/repos/spandex-project/spandex/pulls/80/comments","review_comment_url":"https://api.github.com/repos/spandex-project/spandex/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spandex-project/spandex/issues/80/comments","statuses_url":"https://api.github.com/repos/spandex-project/spandex/statuses/b5a0ed1626543bfc170d063b8c6c1b46ed2638e7","head":{"label":"dnlserrano:bring-back-trace-decorator","ref":"bring-back-trace-decorator","sha":"b5a0ed1626543bfc170d063b8c6c1b46ed2638e7","user":{"login":"dnlserrano","id":5096953,"node_id":"MDQ6VXNlcjUwOTY5NTM=","avatar_url":"https://avatars1.githubusercontent.com/u/5096953?v=4","gravatar_id":"","url":"https://api.github.com/users/dnlserrano","html_url":"https://github.com/dnlserrano","followers_url":"https://api.github.com/users/dnlserrano/followers","following_url":"https://api.github.com/users/dnlserrano/following{/other_user}","gists_url":"https://api.github.com/users/dnlserrano/gists{/gist_id}","starred_url":"https://api.github.com/users/dnlserrano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnlserrano/subscriptions","organizations_url":"https://api.github.com/users/dnlserrano/orgs","repos_url":"https://api.github.com/users/dnlserrano/repos","events_url":"https://api.github.com/users/dnlserrano/events{/privacy}","received_events_url":"https://api.github.com/users/dnlserrano/received_events","type":"User","site_admin":false},"repo":{"id":149793322,"node_id":"MDEwOlJlcG9zaXRvcnkxNDk3OTMzMjI=","name":"spandex","full_name":"dnlserrano/spandex","private":false,"owner":{"login":"dnlserrano","id":5096953,"node_id":"MDQ6VXNlcjUwOTY5NTM=","avatar_url":"https://avatars1.githubusercontent.com/u/5096953?v=4","gravatar_id":"","url":"https://api.github.com/users/dnlserrano","html_url":"https://github.com/dnlserrano","followers_url":"https://api.github.com/users/dnlserrano/followers","following_url":"https://api.github.com/users/dnlserrano/following{/other_user}","gists_url":"https://api.github.com/users/dnlserrano/gists{/gist_id}","starred_url":"https://api.github.com/users/dnlserrano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnlserrano/subscriptions","organizations_url":"https://api.github.com/users/dnlserrano/orgs","repos_url":"https://api.github.com/users/dnlserrano/repos","events_url":"https://api.github.com/users/dnlserrano/events{/privacy}","received_events_url":"https://api.github.com/users/dnlserrano/received_events","type":"User","site_admin":false},"html_url":"https://github.com/dnlserrano/spandex","description":"A platform agnostic tracing library","fork":true,"url":"https://api.github.com/repos/dnlserrano/spandex","forks_url":"https://api.github.com/repos/dnlserrano/spandex/forks","keys_url":"https://api.github.com/repos/dnlserrano/spandex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dnlserrano/spandex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dnlserrano/spandex/teams","hooks_url":"https://api.github.com/repos/dnlserrano/spandex/hooks","issue_events_url":"https://api.github.com/repos/dnlserrano/spandex/issues/events{/number}","events_url":"https://api.github.com/repos/dnlserrano/spandex/events","assignees_url":"https://api.github.com/repos/dnlserrano/spandex/assignees{/user}","branches_url":"https://api.github.com/repos/dnlserrano/spandex/branches{/branch}","tags_url":"https://api.github.com/repos/dnlserrano/spandex/tags","blobs_url":"https://api.github.com/repos/dnlserrano/spandex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dnlserrano/spandex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dnlserrano/spandex/git/refs{/sha}","trees_url":"https://api.github.com/repos/dnlserrano/spandex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dnlserrano/spandex/statuses/{sha}","languages_url":"https://api.github.com/repos/dnlserrano/spandex/languages","stargazers_url":"https://api.github.com/repos/dnlserrano/spandex/stargazers","contributors_url":"https://api.github.com/repos/dnlserrano/spandex/contributors","subscribers_url":"https://api.github.com/repos/dnlserrano/spandex/subscribers","subscription_url":"https://api.github.com/repos/dnlserrano/spandex/subscription","commits_url":"https://api.github.com/repos/dnlserrano/spandex/commits{/sha}","git_commits_url":"https://api.github.com/repos/dnlserrano/spandex/git/commits{/sha}","comments_url":"https://api.github.com/repos/dnlserrano/spandex/comments{/number}","issue_comment_url":"https://api.github.com/repos/dnlserrano/spandex/issues/comments{/number}","contents_url":"https://api.github.com/repos/dnlserrano/spandex/contents/{+path}","compare_url":"https://api.github.com/repos/dnlserrano/spandex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dnlserrano/spandex/merges","archive_url":"https://api.github.com/repos/dnlserrano/spandex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dnlserrano/spandex/downloads","issues_url":"https://api.github.com/repos/dnlserrano/spandex/issues{/number}","pulls_url":"https://api.github.com/repos/dnlserrano/spandex/pulls{/number}","milestones_url":"https://api.github.com/repos/dnlserrano/spandex/milestones{/number}","notifications_url":"https://api.github.com/repos/dnlserrano/spandex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dnlserrano/spandex/labels{/name}","releases_url":"https://api.github.com/repos/dnlserrano/spandex/releases{/id}","deployments_url":"https://api.github.com/repos/dnlserrano/spandex/deployments","created_at":"2018-09-21T17:03:47Z","updated_at":"2018-09-21T17:03:49Z","pushed_at":"2018-10-04T13:29:39Z","git_url":"git://github.com/dnlserrano/spandex.git","ssh_url":"git@github.com:dnlserrano/spandex.git","clone_url":"https://github.com/dnlserrano/spandex.git","svn_url":"https://github.com/dnlserrano/spandex","homepage":"","size":331,"stargazers_count":0,"watchers_count":0,"language":"Elixir","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"spandex-project:master","ref":"master","sha":"7a2542f3bf8639d45254fcb571edeb82d1f728ae","user":{"login":"spandex-project","id":42629984,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNjI5OTg0","avatar_url":"https://avatars2.githubusercontent.com/u/42629984?v=4","gravatar_id":"","url":"https://api.github.com/users/spandex-project","html_url":"https://github.com/spandex-project","followers_url":"https://api.github.com/users/spandex-project/followers","following_url":"https://api.github.com/users/spandex-project/following{/other_user}","gists_url":"https://api.github.com/users/spandex-project/gists{/gist_id}","starred_url":"https://api.github.com/users/spandex-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spandex-project/subscriptions","organizations_url":"https://api.github.com/users/spandex-project/orgs","repos_url":"https://api.github.com/users/spandex-project/repos","events_url":"https://api.github.com/users/spandex-project/events{/privacy}","received_events_url":"https://api.github.com/users/spandex-project/received_events","type":"Organization","site_admin":false},"repo":{"id":94697872,"node_id":"MDEwOlJlcG9zaXRvcnk5NDY5Nzg3Mg==","name":"spandex","full_name":"spandex-project/spandex","private":false,"owner":{"login":"spandex-project","id":42629984,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNjI5OTg0","avatar_url":"https://avatars2.githubusercontent.com/u/42629984?v=4","gravatar_id":"","url":"https://api.github.com/users/spandex-project","html_url":"https://github.com/spandex-project","followers_url":"https://api.github.com/users/spandex-project/followers","following_url":"https://api.github.com/users/spandex-project/following{/other_user}","gists_url":"https://api.github.com/users/spandex-project/gists{/gist_id}","starred_url":"https://api.github.com/users/spandex-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spandex-project/subscriptions","organizations_url":"https://api.github.com/users/spandex-project/orgs","repos_url":"https://api.github.com/users/spandex-project/repos","events_url":"https://api.github.com/users/spandex-project/events{/privacy}","received_events_url":"https://api.github.com/users/spandex-project/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/spandex-project/spandex","description":"A platform agnostic tracing library","fork":false,"url":"https://api.github.com/repos/spandex-project/spandex","forks_url":"https://api.github.com/repos/spandex-project/spandex/forks","keys_url":"https://api.github.com/repos/spandex-project/spandex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spandex-project/spandex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spandex-project/spandex/teams","hooks_url":"https://api.github.com/repos/spandex-project/spandex/hooks","issue_events_url":"https://api.github.com/repos/spandex-project/spandex/issues/events{/number}","events_url":"https://api.github.com/repos/spandex-project/spandex/events","assignees_url":"https://api.github.com/repos/spandex-project/spandex/assignees{/user}","branches_url":"https://api.github.com/repos/spandex-project/spandex/branches{/branch}","tags_url":"https://api.github.com/repos/spandex-project/spandex/tags","blobs_url":"https://api.github.com/repos/spandex-project/spandex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spandex-project/spandex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spandex-project/spandex/git/refs{/sha}","trees_url":"https://api.github.com/repos/spandex-project/spandex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spandex-project/spandex/statuses/{sha}","languages_url":"https://api.github.com/repos/spandex-project/spandex/languages","stargazers_url":"https://api.github.com/repos/spandex-project/spandex/stargazers","contributors_url":"https://api.github.com/repos/spandex-project/spandex/contributors","subscribers_url":"https://api.github.com/repos/spandex-project/spandex/subscribers","subscription_url":"https://api.github.com/repos/spandex-project/spandex/subscription","commits_url":"https://api.github.com/repos/spandex-project/spandex/commits{/sha}","git_commits_url":"https://api.github.com/repos/spandex-project/spandex/git/commits{/sha}","comments_url":"https://api.github.com/repos/spandex-project/spandex/comments{/number}","issue_comment_url":"https://api.github.com/repos/spandex-project/spandex/issues/comments{/number}","contents_url":"https://api.github.com/repos/spandex-project/spandex/contents/{+path}","compare_url":"https://api.github.com/repos/spandex-project/spandex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spandex-project/spandex/merges","archive_url":"https://api.github.com/repos/spandex-project/spandex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spandex-project/spandex/downloads","issues_url":"https://api.github.com/repos/spandex-project/spandex/issues{/number}","pulls_url":"https://api.github.com/repos/spandex-project/spandex/pulls{/number}","milestones_url":"https://api.github.com/repos/spandex-project/spandex/milestones{/number}","notifications_url":"https://api.github.com/repos/spandex-project/spandex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spandex-project/spandex/labels{/name}","releases_url":"https://api.github.com/repos/spandex-project/spandex/releases{/id}","deployments_url":"https://api.github.com/repos/spandex-project/spandex/deployments","created_at":"2017-06-18T16:02:03Z","updated_at":"2018-10-02T20:14:02Z","pushed_at":"2018-10-04T13:29:41Z","git_url":"git://github.com/spandex-project/spandex.git","ssh_url":"git@github.com:spandex-project/spandex.git","clone_url":"https://github.com/spandex-project/spandex.git","svn_url":"https://github.com/spandex-project/spandex","homepage":"","size":330,"stargazers_count":73,"watchers_count":73,"language":"Elixir","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":13,"open_issues":7,"watchers":73,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spandex-project/spandex/pulls/80"},"html":{"href":"https://github.com/spandex-project/spandex/pull/80"},"issue":{"href":"https://api.github.com/repos/spandex-project/spandex/issues/80"},"comments":{"href":"https://api.github.com/repos/spandex-project/spandex/issues/80/comments"},"review_comments":{"href":"https://api.github.com/repos/spandex-project/spandex/pulls/80/comments"},"review_comment":{"href":"https://api.github.com/repos/spandex-project/spandex/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spandex-project/spandex/pulls/80/commits"},"statuses":{"href":"https://api.github.com/repos/spandex-project/spandex/statuses/b5a0ed1626543bfc170d063b8c6c1b46ed2638e7"}},"author_association":"NONE"}}
{"actor":{"display_login":"zachdaniel"}}