{"action":"created","issue":{"url":"https://api.github.com/repos/census-instrumentation/opencensus-erlang/issues/54","repository_url":"https://api.github.com/repos/census-instrumentation/opencensus-erlang","labels_url":"https://api.github.com/repos/census-instrumentation/opencensus-erlang/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/census-instrumentation/opencensus-erlang/issues/54/comments","events_url":"https://api.github.com/repos/census-instrumentation/opencensus-erlang/issues/54/events","html_url":"https://github.com/census-instrumentation/opencensus-erlang/issues/54","id":300785414,"number":54,"title":"Handling orphaned spans","user":{"login":"tsloughter","id":36227,"avatar_url":"https://avatars2.githubusercontent.com/u/36227?v=4","gravatar_id":"","url":"https://api.github.com/users/tsloughter","html_url":"https://github.com/tsloughter","followers_url":"https://api.github.com/users/tsloughter/followers","following_url":"https://api.github.com/users/tsloughter/following{/other_user}","gists_url":"https://api.github.com/users/tsloughter/gists{/gist_id}","starred_url":"https://api.github.com/users/tsloughter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsloughter/subscriptions","organizations_url":"https://api.github.com/users/tsloughter/orgs","repos_url":"https://api.github.com/users/tsloughter/repos","events_url":"https://api.github.com/users/tsloughter/events{/privacy}","received_events_url":"https://api.github.com/users/tsloughter/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-27T20:42:54Z","updated_at":"2018-02-27T20:57:11Z","closed_at":null,"author_association":"MEMBER","body":"In the event `finish` is never called for a span context the span data will currently live on forever in the ets table.\r\n\r\nThere should be either a new process that does a clean operation on the table, or could have it happen when the reporter runs, and have it check spans against a configurable TTL, deleting those that are too old and deemed abandoned. \r\n\r\nOptionally the pid each span was created in could be added to the data and used to know if a span should be finished/removed. There could even be a monitor to track the span's owner and finish it on a down message.\r\n\r\nI'd argue for just the TTL, it is the simplest and least likely to result in much overhead or flooded process. But there may be something to supporting a span that exists for the life of a process, being an optional way of creating a span:\r\n\r\n```erlang\r\noc_trace:spawn_span(<<\"name\">>, fun() -> i_get_traced end)\r\n```\r\n\r\nWhere `oc_trace:spawn` is basically:\r\n\r\n```erlang\r\nspawn_span(Name, Fun) ->\r\n  erlang:spawn(fun() ->\r\n    SpanCtx = oc_trace:start_span(Name),\r\n    {Pid, Ref} = erlang:spawn_monitor(fun() ->\r\n                          ocp:with_span(SpanCtx),\r\n                          Fun()\r\n                        end),\r\n    receive\r\n        {'DOWN' ...} ->\r\n            oc_trace:finish_span(SpanCtx)\r\n    end\r\n  end).\r\n```\r\n\r\nOr have a single/pool of processes responsible for doing the monitoring and just send it a message instead of having to spawn twice."},"comment":{"url":"https://api.github.com/repos/census-instrumentation/opencensus-erlang/issues/comments/369023242","html_url":"https://github.com/census-instrumentation/opencensus-erlang/issues/54#issuecomment-369023242","issue_url":"https://api.github.com/repos/census-instrumentation/opencensus-erlang/issues/54","id":369023242,"user":{"login":"deadtrickster","id":172311,"avatar_url":"https://avatars1.githubusercontent.com/u/172311?v=4","gravatar_id":"","url":"https://api.github.com/users/deadtrickster","html_url":"https://github.com/deadtrickster","followers_url":"https://api.github.com/users/deadtrickster/followers","following_url":"https://api.github.com/users/deadtrickster/following{/other_user}","gists_url":"https://api.github.com/users/deadtrickster/gists{/gist_id}","starred_url":"https://api.github.com/users/deadtrickster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deadtrickster/subscriptions","organizations_url":"https://api.github.com/users/deadtrickster/orgs","repos_url":"https://api.github.com/users/deadtrickster/repos","events_url":"https://api.github.com/users/deadtrickster/events{/privacy}","received_events_url":"https://api.github.com/users/deadtrickster/received_events","type":"User","site_admin":false},"created_at":"2018-02-27T20:57:11Z","updated_at":"2018-02-27T20:57:11Z","author_association":"MEMBER","body":"in face spawn_span can also handle Parent context transfer. It's one of the options. Reasonable default? TTL sounds good too, then just run match spec."}}
{"actor":{"display_login":"deadtrickster"}}