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

Dynamic subscribers MFA does not work #61

Open
eproxus opened this issue Jan 11, 2016 · 3 comments
Open

Dynamic subscribers MFA does not work #61

eproxus opened this issue Jan 11, 2016 · 3 comments

Comments

@eproxus
Copy link

eproxus commented Jan 11, 2016

The following configuration works:

{exometer_core, [
  {predefined, {apply, stats, entries, []},
  {report, [
    {reporters, [
      {exometer_report_librato, [...]}
    ]},
    {subscribers, [
      {exometer_report_librato, [erlang, memory], [total, processes, processes_used, system, atom, atom_used, binary, code, ets], 5000},
    ]},
  ]}
]}.

Result:

1> exometer_report:list_subscriptions(exometer_report_librato).
[{[erlang,memory],
  [total,processes,processes_used,system,atom,atom_used,binary,code,ets],
  5000,undefined}]

The following does not:

{exometer_core, [
  {predefined, {apply, stats, entries, []},
  {report, [
    {reporters, [
      {exometer_report_librato, [...]}
    ]},
    {subscribers, [{apply, stats, subscribers, []}]}
  ]}
]}.

Result:

1> exometer_report:list_subscriptions(exometer_report_librato).
[]

Implementation of stats.erl:

-module(stats).

-export([entries/0]).
-export([subscribers/0]).


entries() ->
    {ok, [
        {
            [erlang, memory],
            {function, erlang, memory, [], proplist, [total, processes, processes_used, system, atom, atom_used, binary, code, ets]},
            []
        },
    ]}.

subscribers() ->
    [
        % Complete copy of what is in the sys.config
        {exometer_report_librato, [erlang, memory], [total, processes, processes_used, system, atom, atom_used, binary, code, ets], 5000}
    ].
@tolbrino
Copy link
Contributor

@eproxus The MFA should be a tuple instead of simple values in the list. Try

{exometer_core, [
  {predefined, {apply, stats, entries, []},
  {report, [
    {reporters, [
      {exometer_report_librato, [...]}
    ]},
    {subscribers, [{apply, {stats, subscribers, []}}]}
  ]}
]}.

@eproxus
Copy link
Author

eproxus commented Jan 18, 2016

Ok, that works. 😄

Two things: in predefined entries, the format is {apply, M, F, A} which is confusing, and I think invalid subscription formats should be rejected (although in this case it matches the {Reporter, Metric, DataPoint, Interval} pattern, so I'm not sure what would be the best way).

Also, the documentation says directly after the correct description:

In the case of {apply, M, F, A}, the result of apply(M, F, A) must be a list of subscribers tuples.

@tolbrino
Copy link
Contributor

It is confusing, I agree. I guess it would be best to change how apply works for predefined entries to be in sync with how it works for subscriptions.

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

No branches or pull requests

2 participants