Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double send measurements #106

Closed
wants to merge 2 commits into from

Conversation

gpad
Copy link

@gpad gpad commented Feb 15, 2018

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):

2018-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
2018-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
2018-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
2018-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
2018-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
2018-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

Debugging 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.

adjust_interval(Interval, T0) ->
    Now = os:timestamp(),
    case tdiff(Now, T0) of
        Elapsed when Elapsed > Interval; Elapsed < 0 ->
            %% Most likely due to clock adjustment
            {Interval, Now};
        Elapsed ->
            {Interval - Elapsed, T0}
    end.

@gpad gpad mentioned this pull request Feb 15, 2018
@uwiger
Copy link
Member

uwiger commented Feb 15, 2018

Ah, I was just looking at that myself, and created my own PR. I could have saved some time by checking my email first. :)

@@ -9,6 +9,7 @@

{deps,
[
{lager, ".*", {git, "git://github.com/basho/lager.git", {tag,"3.0.2"}}},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, hut handles the logging (possibly with lager) in exometer_core.

@uwiger
Copy link
Member

uwiger commented Feb 15, 2018

Since my PR is identical, except for the change in rebar.config, I'll just go ahead and merge that instead. Thanks for the contribution, though!

@uwiger uwiger closed this Feb 15, 2018
@gpad
Copy link
Author

gpad commented Feb 15, 2018

I need to add lager because using this branch directly in a elixir project doesn't compile the exometer package (I don't known why?!?) so I need to add it. I also open the issue #107. When do you plan to release a new version on hex.pm? thanks

@uwiger
Copy link
Member

uwiger commented Feb 18, 2018

You can find the discussion leading up to the removal of lager from exometer_core here:
#57

@gpad
Copy link
Author

gpad commented Feb 23, 2018

@uwiger I check the discussion and you are right it's not necessary add lager on exometer_core. In my app I need exometer_report_statsd that is in exometer and in exometer master there is a reference to exometer_collectd tag, "1.0.1" that still use lager. Forcing to use the master also for exometer_collectd everything work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants