./ct_report/coverage/mongoose_graphql_metric_admin_query.COVER.html

1 -module(mongoose_graphql_metric_admin_query).
2 -behaviour(mongoose_graphql).
3
4 -export([execute/4]).
5
6 -ignore_xref([execute/4]).
7
8 execute(_Ctx, _Obj, <<"getMetrics">>, Args) ->
9
:-(
Name = get_name(Args),
10
:-(
mongoose_metrics_api:get_metrics(Name);
11 execute(_Ctx, _Obj, <<"getMetricsAsDicts">>, Args) ->
12
:-(
Name = get_name(Args),
13
:-(
Keys = get_keys2(Args),
14
:-(
mongoose_metrics_api:get_metrics_as_dicts(Name, Keys);
15 execute(_Ctx, _Obj, <<"getClusterMetricsAsDicts">>, Args) ->
16
:-(
Name = get_name(Args),
17
:-(
Keys = get_keys2(Args),
18
:-(
Nodes = get_nodes(Args),
19
:-(
mongoose_metrics_api:get_cluster_metrics_as_dicts(Name, Keys, Nodes).
20
21 %% get_keys is a BIF, so we have a name conflict
22 get_keys2(Args) ->
23
:-(
Keys = get_list(<<"keys">>, Args),
24
:-(
lists:map(fun prepare_key/1, Keys).
25
26 prepare_key(X) when is_binary(X) ->
27
:-(
binary_to_atom(X);
28 prepare_key(X) when is_integer(X) -> %% For percentiles
29
:-(
X.
30
31 get_name(Args) ->
32
:-(
Segments = get_list(<<"name">>, Args),
33
:-(
lists:map(fun binary_to_atom/1, Segments).
34
35 get_nodes(Args) ->
36
:-(
Nodes = get_list(<<"nodes">>, Args),
37
:-(
lists:map(fun binary_to_atom/1, Nodes).
38
39 get_list(Key, Map) ->
40
:-(
null_as_empty(maps:get(Key, Map, [])).
41
42
:-(
null_as_empty(null) -> [];
43
:-(
null_as_empty(X) -> X.
Line Hits Source