-export(
[ of_beam_stats/1
+ , of_beam_stats/2
, to_bin/1
+ , path_to_bin/1
+ , add_path_prefix/2
+ , node_id_to_bin/1
]).
-define(T, #?MODULE).
, timestamp = Timestamp
}
) ->
- PathBin = bin_join(Path, <<".">>),
+ PathBin = path_to_bin(Path),
ValueBin = integer_to_binary(Value),
TimestampInt = timestamp_to_integer(Timestamp),
TimestampBin = integer_to_binary(TimestampInt),
<<PathBin/binary, " ", ValueBin/binary, " ", TimestampBin/binary>>.
+-spec add_path_prefix(t(), binary()) ->
+ t().
+add_path_prefix(?T{path=Path}=T, <<Prefix/binary>>) ->
+ T?T{path = [Prefix | Path]}.
+
+-spec path_to_bin([binary()]) ->
+ binary().
+path_to_bin(Path) ->
+ bin_join(Path, <<".">>).
+
+-spec node_id_to_bin(node()) ->
+ binary().
+node_id_to_bin(NodeID) ->
+ NodeIDBin = atom_to_binary(NodeID, utf8),
+ re:replace(NodeIDBin, "[\@\.]", "_", [global, {return, binary}]).
+
%% ============================================================================
%% Helpers
%% ============================================================================
OriginAndPid = [OriginBin, PidBin],
Ts = Timestamp,
N = NodeID,
- [ cons([N, <<"process_memory">> , OriginAndPid], Memory , Ts)
- , cons([N, <<"process_total_heap_size">> , OriginAndPid], TotalHeapSize , Ts)
- , cons([N, <<"process_stack_size">> , OriginAndPid], StackSize , Ts)
- , cons([N, <<"process_message_queue_len">> , OriginAndPid], MsgQueueLen , Ts)
+ [ cons([N, <<"process_memory">> | OriginAndPid], Memory , Ts)
+ , cons([N, <<"process_total_heap_size">> | OriginAndPid], TotalHeapSize , Ts)
+ , cons([N, <<"process_stack_size">> | OriginAndPid], StackSize , Ts)
+ , cons([N, <<"process_message_queue_len">> | OriginAndPid], MsgQueueLen , Ts)
].
-spec proc_origin_to_bin(beam_stats_process:best_known_origin()) ->
, value = Value
, timestamp = Timestamp
}.
-
--spec node_id_to_bin(node()) ->
- binary().
-node_id_to_bin(NodeID) ->
- NodeIDBin = atom_to_binary(NodeID, utf8),
- re:replace(NodeIDBin, "[\@\.]", "_", [global, {return, binary}]).