X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=src%2Fbeam_stats_msg_graphite.erl;h=d33e45054dc8f6e67a95f60e7e627d4470e481a5;hb=630ad37165fb8c8eef61058291e312b9d8b9de10;hp=26751a5e23c860e935ebadac7bccd9ca96aa1393;hpb=c37a5360de581efa57d792dd3e94ee0514b94914;p=beam_stats.git diff --git a/src/beam_stats_msg_graphite.erl b/src/beam_stats_msg_graphite.erl index 26751a5..d33e450 100644 --- a/src/beam_stats_msg_graphite.erl +++ b/src/beam_stats_msg_graphite.erl @@ -14,8 +14,8 @@ -export( [ of_beam_stats/1 , of_beam_stats/2 - , to_bin/1 - , path_to_bin/1 + , to_iolist/1 + , path_to_iolist/1 , node_id_to_bin/1 ]). @@ -64,25 +64,25 @@ of_beam_stats(#beam_stats ++ of_processes(Processes, NodeID, Ts), lists:map(fun path_prefix_schema_version/1, Msgs). --spec to_bin(t()) -> - binary(). -to_bin( +-spec to_iolist(t()) -> + iolist(). +to_iolist( ?T { path = Path , value = Value , timestamp = Timestamp } ) -> - PathBin = path_to_bin(Path), + PathIOList = path_to_iolist(Path), ValueBin = integer_to_binary(Value), TimestampInt = timestamp_to_integer(Timestamp), TimestampBin = integer_to_binary(TimestampInt), - <>. + [PathIOList, <<" ">>, ValueBin, <<" ">>, TimestampBin]. --spec path_to_bin([binary()]) -> - binary(). -path_to_bin(Path) -> - bin_join(Path, <<".">>). +-spec path_to_iolist([binary()]) -> + iolist(). +path_to_iolist(Path) -> + interleave(Path, <<".">>). -spec node_id_to_bin(node()) -> binary(). @@ -109,13 +109,12 @@ path_prefix(?T{path=Path}=T, <>) -> schema_version() -> <<"beam_stats_v0">>. --spec bin_join([binary()], binary()) -> - binary(). -bin_join([] , <<_/binary>> ) -> <<>>; -bin_join([<> | []] , <<_/binary>> ) -> B; -bin_join([<> | [_|_]=Bins], <>) -> - BinsBin = bin_join(Bins, Sep), - <>. +-spec interleave(iolist(), iodata()) -> + iolist(). +interleave([], _) -> []; +interleave([X], _) -> [X]; +interleave([X|Xs], Sep) -> + [X, Sep | interleave(Xs, Sep)]. -spec timestamp_to_integer(erlang:timestamp()) -> non_neg_integer(). @@ -205,6 +204,7 @@ of_process( , total_heap_size = TotalHeapSize , stack_size = StackSize , message_queue_len = MsgQueueLen + , reductions = Reductions }=Process, <>, Timestamp @@ -217,6 +217,7 @@ of_process( , cons([N, <<"process_total_heap_size">> , OriginBin], TotalHeapSize , Ts) , cons([N, <<"process_stack_size">> , OriginBin], StackSize , Ts) , cons([N, <<"process_message_queue_len">> , OriginBin], MsgQueueLen , Ts) + , cons([N, <<"process_reductions">> , OriginBin], Reductions , Ts) ]. -spec aggregate_by_path([t()], erlang:timestamp()) ->