{"action":"created","issue":{"url":"https://api.github.com/repos/census-instrumentation/opencensus-go/issues/862","repository_url":"https://api.github.com/repos/census-instrumentation/opencensus-go","labels_url":"https://api.github.com/repos/census-instrumentation/opencensus-go/issues/862/labels{/name}","comments_url":"https://api.github.com/repos/census-instrumentation/opencensus-go/issues/862/comments","events_url":"https://api.github.com/repos/census-instrumentation/opencensus-go/issues/862/events","html_url":"https://github.com/census-instrumentation/opencensus-go/issues/862","id":348937417,"node_id":"MDU6SXNzdWUzNDg5Mzc0MTc=","number":862,"title":"Make it possible for opencensus to pass all remaining data to registered exporters when program exits.","user":{"login":"lychung83","id":39741163,"node_id":"MDQ6VXNlcjM5NzQxMTYz","avatar_url":"https://avatars3.githubusercontent.com/u/39741163?v=4","gravatar_id":"","url":"https://api.github.com/users/lychung83","html_url":"https://github.com/lychung83","followers_url":"https://api.github.com/users/lychung83/followers","following_url":"https://api.github.com/users/lychung83/following{/other_user}","gists_url":"https://api.github.com/users/lychung83/gists{/gist_id}","starred_url":"https://api.github.com/users/lychung83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lychung83/subscriptions","organizations_url":"https://api.github.com/users/lychung83/orgs","repos_url":"https://api.github.com/users/lychung83/repos","events_url":"https://api.github.com/users/lychung83/events{/privacy}","received_events_url":"https://api.github.com/users/lychung83/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-09T00:29:41Z","updated_at":"2018-09-04T19:34:18Z","closed_at":null,"author_association":"NONE","body":"Problem:\r\n\r\nWhen exiting a program running opencensus monitoring, some of the data are not passed to exporter. This happens because as one can see in following code, reportUsage() is called only by timer, so when program exists, all data passed to opencensus after last timer firing event are simply lost.\r\n\r\n```\r\nfunc (w *worker) start() {\r\n\tfor {\r\n\t\tselect {\r\n\t\tcase cmd := <-w.c:\r\n\t\t\tcmd.handleCommand(w)\r\n\t\tcase <-w.timer.C:\r\n\t\t\tw.reportUsage(time.Now())\r\n\t\tcase <-w.quit:\r\n\t\t\tw.timer.Stop()\r\n\t\t\tclose(w.c)\r\n\t\t\tw.done <- true\r\n\t\t\treturn\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\n\r\nSolution proposal:\r\n1. Make `func (w *worker) stop()` to be (indirectly) callable by client of package.\r\n2. Make `func (w *worker) start()` to call `w.reportUsage()` before returning when `<-w.quit` is triggered.\r\n"},"comment":{"url":"https://api.github.com/repos/census-instrumentation/opencensus-go/issues/comments/418490909","html_url":"https://github.com/census-instrumentation/opencensus-go/issues/862#issuecomment-418490909","issue_url":"https://api.github.com/repos/census-instrumentation/opencensus-go/issues/862","id":418490909,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODQ5MDkwOQ==","user":{"login":"rakyll","id":108380,"node_id":"MDQ6VXNlcjEwODM4MA==","avatar_url":"https://avatars0.githubusercontent.com/u/108380?v=4","gravatar_id":"","url":"https://api.github.com/users/rakyll","html_url":"https://github.com/rakyll","followers_url":"https://api.github.com/users/rakyll/followers","following_url":"https://api.github.com/users/rakyll/following{/other_user}","gists_url":"https://api.github.com/users/rakyll/gists{/gist_id}","starred_url":"https://api.github.com/users/rakyll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rakyll/subscriptions","organizations_url":"https://api.github.com/users/rakyll/orgs","repos_url":"https://api.github.com/users/rakyll/repos","events_url":"https://api.github.com/users/rakyll/events{/privacy}","received_events_url":"https://api.github.com/users/rakyll/received_events","type":"User","site_admin":false},"created_at":"2018-09-04T19:34:18Z","updated_at":"2018-09-04T19:34:18Z","author_association":"MEMBER","body":"I think we need a global Flush function that reports all the collected points."}}
{"actor":{"display_login":"rakyll"}}