Skip to content

Commit

Permalink
Add agents count metric
Browse files Browse the repository at this point in the history
  • Loading branch information
bzurkowski committed Mar 25, 2017
1 parent e4fe2db commit 28df229
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mas_population.erl
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,14 @@ count_behaviours(Arenas) ->
%% @private
%%------------------------------------------------------------------------------
subscribe_metrics(Behaviours) ->
mas_reporter:subscribe(metric(agents_count), gauge, value),
[mas_reporter:subscribe(metric(Behaviour)) || Behaviour <- Behaviours].

%%------------------------------------------------------------------------------
%% @private
%%------------------------------------------------------------------------------
unsubscribe_metrics(Behaviours) ->
mas_reporter:unsubscribe(metric(agents_count)),
[mas_reporter:unsubscribe(metric(Behaviour)) || Behaviour <- Behaviours].

%%------------------------------------------------------------------------------
Expand All @@ -224,7 +226,9 @@ schedule_metrics_update(#config{write_interval = WriteInterval}) ->
%%------------------------------------------------------------------------------
%% @private
%%------------------------------------------------------------------------------
update_metrics(State = #state{behaviours_counter = Counter}) ->
update_metrics(State) ->
#state{agents = Agents, behaviours_counter = Counter} = State,
mas_reporter:update(metric(agents_count), length(Agents)),
Behaviours = dict:fetch_keys(Counter),
lists:foreach(fun(Behaviour) ->
mas_reporter:update(metric(Behaviour),
Expand Down

0 comments on commit 28df229

Please sign in to comment.