Skip to content

Commit

Permalink
Use grpoc, not generated atoms, for stat process names
Browse files Browse the repository at this point in the history
  • Loading branch information
russelldb committed Mar 29, 2012
1 parent 12c7eb7 commit af1551d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion rebar.config
Expand Up @@ -12,5 +12,6 @@
{basho_stats, ".*", {git, "git://github.com/basho/basho_stats", "HEAD"}},
{riak_sysmon, ".*", {git, "git://github.com/basho/riak_sysmon", {branch, "master"}}},
{webmachine, ".*", {git, "git://github.com/basho/webmachine",
{branch, "master"}}}
{branch, "master"}}},
{gproc, ".*", {git, "https://github.com/esl/gproc.git", {branch, "master"}}}
]}.
13 changes: 7 additions & 6 deletions src/riak_core_metric_proc.erl
Expand Up @@ -37,23 +37,24 @@
%%%===================================================================

start_link(App, Name, Args) ->
RegName = riak_core_metric:regname(App, Name),
gen_server:start_link({local, RegName}, ?MODULE, [{name, Name}|Args], []).
gen_server:start_link(?MODULE, [{app, App}, {name, Name}|Args], []).

update(App, Name, Args) ->
RegName = riak_core_metric:regname(App, Name),
gen_server:cast(RegName, {update, Args}).
Pid = gproc:where({n, l, {App, Name}}),
gen_server:cast(Pid, {update, Args}).

value(App, Name) ->
value(App, Name, []).

value(App, Name, Presentation) ->
RegName = riak_core_metric:regname(App, Name),
{ok, Val} = gen_server:call(RegName, {value, Presentation}),
Pid = gproc:where({n, l, {App, Name}}),
{ok, Val} = gen_server:call(Pid, {value, Presentation}),
Val.

init(Args) ->
Name = proplists:get_value(name, Args),
App = proplists:get_value(app, Args),
true = gproc:reg({n, l, {App, Name}}, ignored),
{type, ShortName} = proplists:lookup(type, Args), %% Does mod need init args?
Mod = mod_from_shortname(ShortName),
Description = proplists:get_value(description, Args),
Expand Down

0 comments on commit af1551d

Please sign in to comment.