Skip to content

Commit ef4146b

Browse files
Merge pull request #866 from rabbitmq/rabbitmq-management-825
Include metrics for the time it takes to obtain a file handle
2 parents c0bd3ba + 1965e83 commit ef4146b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/file_handle_cache.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ open_with_absolute_path(Path, Mode, Options) ->
315315
case IsWriter andalso HasWriter of
316316
true -> {error, writer_exists};
317317
false -> {ok, Ref} = new_closed_handle(Path, Mode1, Options),
318-
case get_or_reopen([{Ref, new}]) of
318+
case get_or_reopen_timed([{Ref, new}]) of
319319
{ok, [_Handle1]} ->
320320
RCount1 = case is_reader(Mode1) of
321321
true -> RCount + 1;
@@ -674,7 +674,7 @@ with_handles(Refs, Fun) ->
674674
with_handles(Refs, reset, Fun).
675675

676676
with_handles(Refs, ReadBuffer, Fun) ->
677-
case get_or_reopen([{Ref, reopen} || Ref <- Refs]) of
677+
case get_or_reopen_timed([{Ref, reopen} || Ref <- Refs]) of
678678
{ok, Handles0} ->
679679
Handles = case ReadBuffer of
680680
reset -> [reset_read_buffer(H) || H <- Handles0];
@@ -712,6 +712,10 @@ with_flushed_handles(Refs, ReadBuffer, Fun) ->
712712
end
713713
end).
714714

715+
get_or_reopen_timed(RefNewOrReopens) ->
716+
file_handle_cache_stats:update(
717+
io_file_handle_open_attempt, fun() -> get_or_reopen(RefNewOrReopens) end).
718+
715719
get_or_reopen(RefNewOrReopens) ->
716720
case partition_handles(RefNewOrReopens) of
717721
{OpenHdls, []} ->

src/file_handle_cache_stats.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
[io_reopen, mnesia_ram_tx, mnesia_disk_tx,
2727
msg_store_read, msg_store_write,
2828
queue_index_journal_write, queue_index_write, queue_index_read]).
29-
-define(COUNT_TIME, [io_sync, io_seek]).
29+
-define(COUNT_TIME, [io_sync, io_seek, io_file_handle_open_attempt]).
3030
-define(COUNT_TIME_BYTES, [io_read, io_write]).
3131

3232
init() ->

0 commit comments

Comments
 (0)