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

exometer predefined only works when predefined list is empty. #70

Open
linearregression opened this issue Mar 10, 2016 · 3 comments
Open

Comments

@linearregression
Copy link

Try to define configs outside of sys.config. The defaults seems to pass but predefined does not except empty. Following is the sys.config; and error trace. A dump of the ets provided at the end.
lager_test is an empty erlang application. exometer_core and lager also added to application source.

In erlang shell:
Steps:

  • ok = exometer_admin:register_application(lager_test)
    application:ensure_all_started(lager_test) (see error log at bottom). <<<<< ERROR

Config files:
sys.config:

        %% Add here extra lager_test flags
        %% Add here extra Nevro flags
        {exometer_defaults, {script, "./config/exometer_defaults.config"}},   <<<<<<<<<<<<<<<<
        {exometer_predefined, {script, "./config/exometer_predefined.config"}},  <<<<<<<<<<<<
        {exometer, [
        ]}
        %{script, "./config/exometer.config"}
    ]},

exometer_defaults.config:


[
    {['_'], function , [{module, exometer_function}]},
    {['_'], counter  , [{module, exometer}]},
    {['_'], histogram, [{module, exometer_histogram}]},
    {['_'], spiral   , [{module, exometer_spiral}]},
    {['_'], duration , [{module, exometer_folsom}]},
    {['_'], meter    , [{module, exometer_folsom}]},
    {['_'], gauge    , [{module, exometer_folsom}]}
].

exometer_predefined.config <<<<<<<<<< only works when exometer_predefined is empty list.


[
   {[a,1], counter, []}
%   ,{[a,2], counter, []}
%   ,{[b,1], counter, []}
 %  ,{[c,1], counter, []}
].

Error:


=INFO REPORT==== 10-Mar-2016::11:51:30 ===
    application: syntax_tools
    exited: stopped
    type: temporary
{error,
    {lager_test,
        {bad_return,
            {{lager_test_app,start,[normal,[]]},
             {'EXIT',
                 {exists,        <<<<<<<<<<<<<<<<<<<<<<<<<<< EXISTS!!!!!!
                     [{exometer_admin,new_entry,3,
                          [{file,
                               "/opt/opensource/lager_test/_build/default/lib/exometer_core/src/exometer_admin.erl"},
                           {line,175}]},
                      {lists,foreach,2,[{file,"lists.erl"},{line,1337}]},
                      {lager_test_app,start,2,
                          [{file,
                               "/opt/opensource/lager_test/_build/dev/lib/lager_test/src/lager_test_app.erl"},
                           {line,27}]},
                      {application_master,start_it_old,4,
                          [{file,"application_master.erl"},{line,273}]}]}}}}}}

A dump of ets:
([email protected])12> ets:i().
id name type size mem owner

1 code set 374 25013 code_server
4098 code_names set 64 8421 code_server
8206 cookies set 0 299 auth
12305 shell_records ordered_set 0 89 <0.33.0>
ac_tab ac_tab set 48 3871 application_controller
file_io_servers file_io_servers set 0 299 file_server_2
global_locks global_locks set 0 299 global_name_server
global_names global_names set 0 299 global_name_server
global_names_ext global_names_ext set 0 299 global_name_server
global_pid_ids global_pid_ids bag 0 299 global_name_server
global_pid_names global_pid_names bag 0 299 global_name_server
inet_cache inet_cache bag 0 299 inet_db
inet_db inet_db set 29 624 inet_db
inet_hosts_byaddr inet_hosts_byaddr bag 0 299 inet_db
inet_hosts_byname inet_hosts_byname bag 0 299 inet_db
inet_hosts_file_byaddr inet_hosts_file_byaddr bag 0 299 inet_db
inet_hosts_file_byname inet_hosts_file_byname bag 0 299 inet_db
sys_dist sys_dist set 0 299 net_kernel
ok

@uwiger
Copy link
Member

uwiger commented Mar 16, 2016

I tried the following:

  • In exometer_core/test, there is a test app called app1. It has some files in priv/ for testing exometer_defaults and exometer_predefined
  • I created a file, app1/priv/exometer_predefined.script to more closely match your example
  • The following worked for me:
$ ERL_LIBS=`pwd`:`pwd`/test:`pwd`/deps erl
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.3  (abort with ^G)
1> application:ensure_all_started(exometer_core).
...
{ok,[syntax_tools,compiler,goldrush,lager,setup,bear,folsom,
     exometer_core]}
11:10:11.707 [info] Application exometer_core started on node nonode@nohost
2> application:load(app1).
ok
3> application:set_env(app1,exometer_defaults,{consult,"$PRIV_DIR/exometer_defaults.eterm"}).
ok
4> application:set_env(app1,exometer_predefined,{script,"$PRIV_DIR/exometer_predefined.script"}).
ok
5> exometer_admin:register_application(app1).
ok
6> exometer:find_entries([]).
[{[c,1],counter,enabled}]
7> ets:tab2list(exometer_shared).
[{exometer_entry,{default,histogram,[h,'']},
                 histogram,undefined,exometer_histogram,1,0,undefined,
                 undefined,[],undefined}]

What I can imagine is happening is that exometer processes your exometer_predefined.config already at startup. When exometer starts, it will automatically pick up any defaults and predefined entries present in loaded applications. The function exometer_admin:register_application/1 is meant for applications that are introduced once exometer is up and running.

If you are unsure about whether the predef file gets loaded more than once, and you don't want to manually check before registering, you can use {re_register, {Name, Type, Options}}.

An obvious improvement would of course be that exometer recognizes that it's already registered the application at startup.

@linearregression
Copy link
Author

There is also a general improvement of helping end user to know what has gone wrong inside exometer_core. For example there are multiple places from exomerter_core that generates {error, unsupported} if user who needs to write their own reporter. But what causes those are like a wild hunt.

@uwiger
Copy link
Member

uwiger commented Mar 16, 2016

Agreed. PRs are welcome. ;-)

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