1 -module(beam_stats_msg_graphite).
3 -include("include/beam_stats.hrl").
4 -include("include/beam_stats_msg_graphite.hrl").
20 -spec of_beam_stats(beam_stats:t()) ->
22 of_beam_stats(#beam_stats{node_id=NodeID}=BeamStats) ->
23 NodeIDBin = node_id_to_bin(NodeID),
24 of_beam_stats(BeamStats, NodeIDBin).
26 -spec of_beam_stats(beam_stats:t(), binary()) ->
28 of_beam_stats(#beam_stats
29 { timestamp = Timestamp
32 % TODO: Handle the rest of data points
33 , io_bytes_in = IOBytesIn
34 , io_bytes_out = IOBytesOut
35 , context_switches = ContextSwitches
36 , reductions = Reductions
37 , run_queue = RunQueue
39 , processes = _Processes
45 [ cons([N, <<"io">> , <<"bytes_in">> ], IOBytesIn , Ts)
46 , cons([N, <<"io">> , <<"bytes_out">>], IOBytesOut , Ts)
47 , cons([N, <<"context_switches">> ], ContextSwitches, Ts)
48 , cons([N, <<"reductions">> ], Reductions , Ts)
49 , cons([N, <<"run_queue">> ], RunQueue , Ts)
50 | of_memory(Memory, NodeID, Ts)
53 -spec of_memory([{atom(), non_neg_integer()}], binary(), erlang:timestamp()) ->
55 of_memory(Memory, <<NodeID/binary>>, Timestamp) ->
58 KeyBin = atom_to_binary(Key, latin1),
59 cons([NodeID, <<"memory">>, KeyBin], Value, Timestamp)
61 lists:map(ComponentToMessage, Memory).
63 -spec cons([binary()], integer(), erlang:timestamp()) ->
65 cons(Path, Value, Timestamp) ->
69 , timestamp = Timestamp
72 -spec node_id_to_bin(node()) ->
74 node_id_to_bin(NodeID) ->
75 NodeIDBin = atom_to_binary(NodeID, utf8),
76 re:replace(NodeIDBin, "[\@\.]", "_", [global, {return, binary}]).