Configure ra metrics handler

[#157193081]
This commit is contained in:
Diana Corbacho 2018-06-06 22:33:03 +01:00 committed by kjnilsson
parent 8ce0dd6fb2
commit baadbe8701
2 changed files with 19 additions and 2 deletions

View File

@ -167,7 +167,8 @@ define test_rabbitmq_config
{loopback_users, []}
]},
{ra, [
{data_dir, "$(RABBITMQ_QUORUM_DIR)"}
{data_dir, "$(RABBITMQ_QUORUM_DIR)"},
{metrics_handler, {rabbit_quorum_queue, io_metrics_handler}}
]}
].
endef
@ -201,7 +202,8 @@ define test_rabbitmq_config_with_tls
]}
]},
{ra, [
{data_dir, "$(RABBITMQ_QUORUM_DIR)"}
{data_dir, "$(RABBITMQ_QUORUM_DIR)"},
{metrics_handler, {rabbit_quorum_queue, io_metrics_handler}}
]}
].
endef
@ -320,6 +322,7 @@ start-brokers start-cluster:
RABBITMQ_SERVER_START_ARGS=" \
-rabbit loopback_users [] \
-ra data_dir "$(RABBITMQ_QUORUM_DIR)"
-ra metrics_handler {rabbit_quorum_queue, io_metrics_handler}
-rabbitmq_management listener [{port,$$((15672 + $$n - 1))}] \
"; \
if test '$@' = 'start-cluster' && test "$$nodename1"; then \

View File

@ -19,6 +19,7 @@
%% stats about read / write operations that go through the fhc.
-export([init/0, update/3, update/2, update/1, get/0]).
-export([safe_update/2]).
-define(TABLE, ?MODULE).
@ -51,6 +52,19 @@ update(Op, Thunk) ->
_ = ets:update_counter(?TABLE, {Op, time}, Time),
Res.
safe_update(Op, Thunk) ->
{Time, Res} = timer_tc(Thunk),
try
_ = ets:update_counter(?TABLE, {Op, count}, 1),
_ = ets:update_counter(?TABLE, {Op, time}, Time)
catch
error:badarg ->
%% This can happen on startup, when ra tries to open a file before
%% the core is initialised.
ok
end,
Res.
update(Op) ->
ets:update_counter(?TABLE, {Op, count}, 1),
ok.