{"action":"created","issue":{"url":"https://api.github.com/repos/Feuerlabs/exometer_core/issues/106","repository_url":"https://api.github.com/repos/Feuerlabs/exometer_core","labels_url":"https://api.github.com/repos/Feuerlabs/exometer_core/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/Feuerlabs/exometer_core/issues/106/comments","events_url":"https://api.github.com/repos/Feuerlabs/exometer_core/issues/106/events","html_url":"https://github.com/Feuerlabs/exometer_core/pull/106","id":297490076,"number":106,"title":"Fix double send measurements","user":{"login":"gpad","id":642430,"avatar_url":"https://avatars0.githubusercontent.com/u/642430?v=4","gravatar_id":"","url":"https://api.github.com/users/gpad","html_url":"https://github.com/gpad","followers_url":"https://api.github.com/users/gpad/followers","following_url":"https://api.github.com/users/gpad/following{/other_user}","gists_url":"https://api.github.com/users/gpad/gists{/gist_id}","starred_url":"https://api.github.com/users/gpad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gpad/subscriptions","organizations_url":"https://api.github.com/users/gpad/orgs","repos_url":"https://api.github.com/users/gpad/repos","events_url":"https://api.github.com/users/gpad/events{/privacy}","received_events_url":"https://api.github.com/users/gpad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-15T15:36:44Z","updated_at":"2018-02-15T18:27:30Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/Feuerlabs/exometer_core/pulls/106","html_url":"https://github.com/Feuerlabs/exometer_core/pull/106","diff_url":"https://github.com/Feuerlabs/exometer_core/pull/106.diff","patch_url":"https://github.com/Feuerlabs/exometer_core/pull/106.patch"},"body":"I found that the measurements are sent 2 times with the same timestamp. To find this bug I configured some predefined measurements, I sent it via statsd subscriber and I set the level of logger to debug. In this way I found that the measurements are sent 2 times on the same seconds (I set the interval to 5 seconds):\r\n\r\n```\r\n2018-02-14 19:04:40.626 [debug] <0.1462.0>@exometer_report_statsd:exometer_report:68 Report metric [<<\"rezolve~core_1@elixir-node_1~local_dev\">>,\".\",\"erlang\",\".\",\"memory\",\".\",\"total\"] = 75257336\r\n2018-02-14 19:04:40.629 [debug] <0.1462.0>@exometer_report_statsd:exometer_report:68 Report metric [<<\"rezolve~core_1@elixir-node_1~local_dev\">>,\".\",\"erlang\",\".\",\"memory\",\".\",\"total\"] = 75248920\r\n```\r\n\r\n```\r\n2018-02-14 19:04:45.631 [debug] <0.1462.0>@exometer_report_statsd:exometer_report:68 Report metric [<<\"rezolve~core_1@elixir-node_1~local_dev\">>,\".\",\"erlang\",\".\",\"memory\",\".\",\"total\"] = 75306448\r\n2018-02-14 19:04:45.636 [debug] <0.1462.0>@exometer_report_statsd:exometer_report:68 Report metric [<<\"rezolve~core_1@elixir-node_1~local_dev\">>,\".\",\"erlang\",\".\",\"memory\",\".\",\"total\"] = 75328744\r\n```\r\n\r\n```\r\n2018-02-14 19:04:50.637 [debug] <0.1462.0>@exometer_report_statsd:exometer_report:68 Report metric [<<\"rezolve~core_1@elixir-node_1~local_dev\">>,\".\",\"erlang\",\".\",\"memory\",\".\",\"total\"] = 75451056\r\n2018-02-14 19:04:50.639 [debug] <0.1462.0>@exometer_report_statsd:exometer_report:68 Report metric [<<\"rezolve~core_1@elixir-node_1~local_dev\">>,\".\",\"erlang\",\".\",\"memory\",\".\",\"total\"] = 75481512\r\n```\r\n\r\nDebugging the code I fix this problem in this way.  I would also rewrite the function in this way that is (for me) more clear but in the PR I change the minimum required. \r\n\r\n```\r\nadjust_interval(Interval, T0) ->\r\n    Now = os:timestamp(),\r\n    case tdiff(Now, T0) of\r\n        Elapsed when Elapsed > Interval; Elapsed < 0 ->\r\n            %% Most likely due to clock adjustment\r\n            {Interval, Now};\r\n        Elapsed ->\r\n            {Interval - Elapsed, T0}\r\n    end.\r\n```"},"comment":{"url":"https://api.github.com/repos/Feuerlabs/exometer_core/issues/comments/366017985","html_url":"https://github.com/Feuerlabs/exometer_core/pull/106#issuecomment-366017985","issue_url":"https://api.github.com/repos/Feuerlabs/exometer_core/issues/106","id":366017985,"user":{"login":"uwiger","id":160216,"avatar_url":"https://avatars3.githubusercontent.com/u/160216?v=4","gravatar_id":"","url":"https://api.github.com/users/uwiger","html_url":"https://github.com/uwiger","followers_url":"https://api.github.com/users/uwiger/followers","following_url":"https://api.github.com/users/uwiger/following{/other_user}","gists_url":"https://api.github.com/users/uwiger/gists{/gist_id}","starred_url":"https://api.github.com/users/uwiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uwiger/subscriptions","organizations_url":"https://api.github.com/users/uwiger/orgs","repos_url":"https://api.github.com/users/uwiger/repos","events_url":"https://api.github.com/users/uwiger/events{/privacy}","received_events_url":"https://api.github.com/users/uwiger/received_events","type":"User","site_admin":false},"created_at":"2018-02-15T18:27:30Z","updated_at":"2018-02-15T18:27:30Z","author_association":"OWNER","body":"Ah, I was just looking at that myself, and created my own PR. I could have saved some time by checking my email first. :)"}}
{"actor":{"display_login":"uwiger"}}