Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit 1af5351

Browse files
dcorbachokjnilsson
authored andcommitted
Configure ra metrics handler
[#157193081]
1 parent e228f26 commit 1af5351

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

mk/rabbitmq-run.mk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ define test_rabbitmq_config
167167
{loopback_users, []}
168168
]},
169169
{ra, [
170-
{data_dir, "$(RABBITMQ_QUORUM_DIR)"}
170+
{data_dir, "$(RABBITMQ_QUORUM_DIR)"},
171+
{metrics_handler, {rabbit_quorum_queue, io_metrics_handler}}
171172
]}
172173
].
173174
endef
@@ -201,7 +202,8 @@ define test_rabbitmq_config_with_tls
201202
]}
202203
]},
203204
{ra, [
204-
{data_dir, "$(RABBITMQ_QUORUM_DIR)"}
205+
{data_dir, "$(RABBITMQ_QUORUM_DIR)"},
206+
{metrics_handler, {rabbit_quorum_queue, io_metrics_handler}}
205207
]}
206208
].
207209
endef
@@ -320,6 +322,7 @@ start-brokers start-cluster:
320322
RABBITMQ_SERVER_START_ARGS=" \
321323
-rabbit loopback_users [] \
322324
-ra data_dir "$(RABBITMQ_QUORUM_DIR)"
325+
-ra metrics_handler {rabbit_quorum_queue, io_metrics_handler}
323326
-rabbitmq_management listener [{port,$$((15672 + $$n - 1))}] \
324327
"; \
325328
if test '$@' = 'start-cluster' && test "$$nodename1"; then \

src/file_handle_cache_stats.erl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
%% stats about read / write operations that go through the fhc.
2020

2121
-export([init/0, update/3, update/2, update/1, get/0]).
22+
-export([safe_update/2]).
2223

2324
-define(TABLE, ?MODULE).
2425

@@ -51,6 +52,19 @@ update(Op, Thunk) ->
5152
_ = ets:update_counter(?TABLE, {Op, time}, Time),
5253
Res.
5354

55+
safe_update(Op, Thunk) ->
56+
{Time, Res} = timer_tc(Thunk),
57+
try
58+
_ = ets:update_counter(?TABLE, {Op, count}, 1),
59+
_ = ets:update_counter(?TABLE, {Op, time}, Time)
60+
catch
61+
error:badarg ->
62+
%% This can happen on startup, when ra tries to open a file before
63+
%% the core is initialised.
64+
ok
65+
end,
66+
Res.
67+
5468
update(Op) ->
5569
ets:update_counter(?TABLE, {Op, count}, 1),
5670
ok.

0 commit comments

Comments
 (0)