Skip to content

Commit b59cbac

Browse files
committed
Add osiris_counters:counters/2 to get n counters
Instead of using osiris_counters:overview/1 and get all counters, this is more efficient.
1 parent c298842 commit b59cbac

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/osiris_counters.erl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
fetch/1,
1313
overview/0,
1414
overview/1,
15+
counters/2,
1516
delete/1
1617
]).
1718

@@ -45,3 +46,7 @@ overview() ->
4546
-spec overview(name()) -> #{atom() => non_neg_integer()} | undefined.
4647
overview(Name) ->
4748
seshat:counters(osiris, Name).
49+
50+
-spec counters(name(), [atom()]) -> #{atom() => non_neg_integer()} | undefined.
51+
counters(Name, Fields) ->
52+
seshat:counters(osiris, Name, Fields).

src/osiris_writer.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
data_listeners = [] :: [{pid(), osiris:offset()}],
7878
offset_listeners = [] ::
7979
[{pid(), osiris:offset(), mfa() | undefined}],
80-
committed_chk_id = -1 :: osiris:offset()}). %% committed chunk ID
80+
committed_chk_id = -1 :: osiris:offset()}).
8181

8282
-opaque state() :: #?MODULE{}.
8383

test/osiris_SUITE.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,9 @@ cluster_restart_large(Config) ->
843843

844844
%% wait for replica key counters to match writer
845845
await_condition(fun () ->
846-
RC = erpc:call(hd(Replicas), osiris_counters, overview,
847-
[{osiris_replica, Name}]),
848-
maps:with(Keys, CountersPre) == maps:with(Keys, RC)
846+
RC = erpc:call(hd(Replicas), osiris_counters, counters,
847+
[{osiris_replica, Name}, Keys]),
848+
maps:with(Keys, CountersPre) == RC
849849
end, 1000, 20),
850850
Replica1CountersPre = erpc:call(hd(Replicas), osiris_counters, overview,
851851
[{osiris_replica, Name}]),

0 commit comments

Comments
 (0)