./ct_report/coverage/mongoose_instrument_registry.COVER.html

1 -module(mongoose_instrument_registry).
2
3 -export([start/0, attach/3, detach/2, lookup/2]).
4
5 -spec start() -> ok.
6 start() ->
7 33 ets:new(?MODULE, [named_table, public, {read_concurrency, true}]),
8 33 ok.
9
10 -spec attach(mongoose_instrument:event_name(), mongoose_instrument:labels(),
11 mongoose_instrument:handlers()) -> ok.
12 attach(Event, Labels, Val) ->
13
:-(
ets:insert_new(?MODULE, {{Event, Labels}, Val}),
14
:-(
ok.
15
16 -spec detach(mongoose_instrument:event_name(), mongoose_instrument:labels()) -> ok.
17 detach(Event, Labels) ->
18
:-(
ets:delete(?MODULE, {Event, Labels}),
19
:-(
ok.
20
21 -spec lookup(mongoose_instrument:event_name(), mongoose_instrument:labels()) ->
22 {ok, mongoose_instrument:handlers()} | {error, not_found}.
23 lookup(Event, Labels) ->
24
:-(
case ets:lookup(?MODULE, {Event, Labels}) of
25
:-(
[] -> {error, not_found};
26
:-(
[{_, Val}] -> {ok, Val}
27 end.
Line Hits Source