, io_bytes_in :: non_neg_integer()
, io_bytes_out :: non_neg_integer()
, context_switches :: non_neg_integer()
+ , reductions :: non_neg_integer()
%, statistics :: [{atom() , term()}]
%, system :: [{atom() , term()}]
%, process :: [{atom() , term()}]
, io_bytes_in = IOBytesIn
, io_bytes_out = IOBytesOut
, context_switches = ContextSwitches
+ , reductions = Reductions
}
) ->
NodeIDBin = node_id_to_bin(NodeID),
[ io_bytes_in_to_msg(IOBytesIn)
, io_bytes_out_to_msg(IOBytesOut)
, context_switches_to_msg(ContextSwitches)
+ , reductions_to_msg(Reductions)
| memory_to_msgs(Memory)
],
Msgs2 = [statsd_msg_add_name_prefix(M, NodeIDBin) || M <- Msgs1],
[statsd_msg_to_bin(M) || M <- Msgs2].
+-spec reductions_to_msg(non_neg_integer()) ->
+ statsd_msg().
+reductions_to_msg(Reductions) ->
+ #statsd_msg
+ { name = <<"reductions">>
+ , value = Reductions
+ , type = gauge
+ }.
+
-spec context_switches_to_msg(non_neg_integer()) ->
statsd_msg().
context_switches_to_msg(ContextSwitches) ->
, previous_context_switches :: non_neg_integer()
, current_context_switches :: non_neg_integer()
+
+ , reductions :: non_neg_integer()
}).
-define(T, #?MODULE).
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
{CurrentContextSwitches, 0} = erlang:statistics(context_switches),
+ {_ReductionsTotal, ReductionsDelta} = erlang:statistics(reductions),
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
, current_io_bytes_out = CurrentIOBytesOut
, previous_context_switches = 0
, current_context_switches = CurrentContextSwitches
+ , reductions = ReductionsDelta
}.
-spec update(t()) ->
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
{CurrentContextSwitches, 0} = erlang:statistics(context_switches),
+ {_ReductionsTotal, ReductionsDelta} = erlang:statistics(reductions),
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
, current_io_bytes_out = CurrentIOBytesOut
, previous_context_switches = PreviousContextSwitches
, current_context_switches = CurrentContextSwitches
+ , reductions = ReductionsDelta
}.
-spec export(t()) ->
, current_io_bytes_out = CurrentIOBytesOut
, previous_context_switches = PreviousContextSwitches
, current_context_switches = CurrentContextSwitches
+ , reductions = Reductions
}
) ->
#beam_stats
, io_bytes_in = CurrentIOBytesIn - PreviousIOBytesIn
, io_bytes_out = CurrentIOBytesOut - PreviousIOBytesOut
, context_switches = CurrentContextSwitches - PreviousContextSwitches
+ , reductions = Reductions
}.
, io_bytes_in = 3
, io_bytes_out = 7
, context_switches = 5
+ , reductions = 9
},
ServerPort = 8125,
{ok, ServerSocket} = gen_udp:open(ServerPort, [binary, {active, false}]),
<< "beam_stats.node_foo_host_bar.io.bytes_in:3|g\n"
, "beam_stats.node_foo_host_bar.io.bytes_out:7|g\n"
, "beam_stats.node_foo_host_bar.context_switches:5|g\n"
+ , "beam_stats.node_foo_host_bar.reductions:9|g\n"
, "beam_stats.node_foo_host_bar.memory.mem_type_foo:1|g\n"
>> = Data.