Skip to content

Commit

Permalink
Fix RDBMS metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Jun 2, 2022
1 parent 4c1881c commit 21ec042
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
6 changes: 6 additions & 0 deletions big_tests/tests/graphql_metric_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ type_to_keys(<<"gauge">>) ->
type_to_keys(<<"merged_inet_stats">>) ->
[<<"connections">>, <<"recv_cnt">>, <<"recv_max">>, <<"recv_oct">>,
<<"send_cnt">>, <<"send_max">>, <<"send_oct">>, <<"send_pend">>];
type_to_keys(<<"rdbms_stats">>) ->
[<<"workers">>, <<"recv_cnt">>, <<"recv_max">>, <<"recv_oct">>,
<<"send_cnt">>, <<"send_max">>, <<"send_oct">>, <<"send_pend">>];
type_to_keys(<<"vm_stats_memory">>) ->
[<<"atom_used">>, <<"binary">>, <<"ets">>,
<<"processes_used">>, <<"system">>, <<"total">>];
Expand Down Expand Up @@ -254,6 +257,9 @@ get_metrics_call_with_args(Args) ->
... on MergedInetStatsMetric
{ name type connections recv_cnt recv_max recv_oct
send_cnt send_max send_oct send_pend }
... on RDBMSStatsMetric
{ name type workers recv_cnt recv_max recv_oct
send_cnt send_max send_oct send_pend }
... on VMStatsMemoryMetric
{ name type total processes_used atom_used binary ets system }
... on VMSystemInfoMetric
Expand Down
26 changes: 25 additions & 1 deletion priv/graphql/schemas/admin/metric.gql
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ enum MetricType {
spiral
gauge
merged_inet_stats
rdbms_stats
vm_stats_memory
vm_system_info
probe_queues
}

union MetricResult = HistogramMetric | CounterMetric | SpiralMetric
| GaugeMetric | MergedInetStatsMetric
| GaugeMetric | MergedInetStatsMetric | RDBMSStatsMetric
| VMStatsMemoryMetric | VMSystemInfoMetric
| ProbeQueuesMetric

Expand Down Expand Up @@ -100,6 +101,29 @@ type MergedInetStatsMetric {
send_pend: Int
}

type RDBMSStatsMetric {
"Metric name"
name: [String]
"Metric type"
type: MetricType
"Number of workers"
workers: Int
"Number of packets received by the socket"
recv_cnt: Int
"Size of the largest packet, in bytes, received by the socket"
recv_max: Int
"Number of bytes received by the socket"
recv_oct: Int
"Number of packets sent from the socket"
send_cnt: Int
"Size of the largest packet, in bytes, sent from the socket"
send_max: Int
"Number of bytes sent from the socket"
send_oct: Int
"Number of bytes waiting to be sent by the socket"
send_pend: Int
}

type VMStatsMemoryMetric {
"Metric name"
name: [String]
Expand Down
12 changes: 11 additions & 1 deletion src/graphql/admin/mongoose_graphql_metric_admin_query.erl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ format_dict2(#{processes_used := _} = Dict) ->
format_dict2(#{port_count := _} = Dict) ->
format_vm_system_info(Dict);
format_dict2(#{fsm := _, regular := _} = Dict) ->
format_probe_queues(Dict).
format_probe_queues(Dict);
format_dict2(#{recv_cnt := _, workers := _} = Dict) ->
format_rdbms_stats(Dict).

format_spiral(#{one := One, count := Count}) ->
#{<<"type">> => <<"spiral">>, <<"one">> => One, <<"count">> => Count}.
Expand Down Expand Up @@ -161,6 +163,14 @@ format_merged_inet_stats(#{connections := Cons,
<<"send_cnt">> => SCnt, <<"send_max">> => SMax, <<"send_oct">> => SOct,
<<"send_pend">> => SPend}.

format_rdbms_stats(#{recv_cnt := RCnt, recv_max := RMax, recv_oct := ROct,
send_cnt := SCnt,send_max := SMax, send_oct := SOct,
send_pend := SPend, workers := Workers}) ->
#{<<"type">> => <<"rdbms_stats">>, <<"workers">> => Workers,
<<"recv_cnt">> => RCnt, <<"recv_max">> => RMax, <<"recv_oct">> => ROct,
<<"send_cnt">> => SCnt, <<"send_max">> => SMax, <<"send_oct">> => SOct,
<<"send_pend">> => SPend}.

format_vm_stats_memory(#{total := Total, processes_used := P,
atom_used := A, binary := B, ets := E, system := S}) ->
#{<<"type">> => <<"vm_stats_memory">>,
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/mongoose_graphql_union.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ execute(#{<<"type">> := <<"vm_system_info">>, <<"port_count">> := _}) ->
{ok, <<"VMSystemInfoMetric">>};
execute(#{<<"type">> := <<"probe_queues">>, <<"fsm">> := _}) ->
{ok, <<"ProbeQueuesMetric">>};
execute(#{<<"type">> := <<"rdbms_stats">>, <<"workers">> := _}) ->
{ok, <<"RDBMSStatsMetric">>};
execute(Value) ->
?LOG_ERROR(#{what => graphql_unknown_type, value => Value}),
{error, unknown_type}.

0 comments on commit 21ec042

Please sign in to comment.