X-Git-Url: https://git.xandkar.net/?p=beam_stats.git;a=blobdiff_plain;f=src%2Fbeam_stats_msg_graphite.erl;h=c88e3270d0c79c4363f45fc9c2f575581b52876f;hp=6883ff17beca508c21a53f0f46198942cf05f98c;hb=ece99ea366e3bc8720528aaf5e1e1563e85b561c;hpb=8dd2cb56d2a0baabacfbab3795e8c7bffb5c06b5 diff --git a/src/beam_stats_msg_graphite.erl b/src/beam_stats_msg_graphite.erl index 6883ff1..c88e327 100644 --- a/src/beam_stats_msg_graphite.erl +++ b/src/beam_stats_msg_graphite.erl @@ -13,8 +13,11 @@ -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). @@ -76,11 +79,22 @@ to_bin( TimestampBin = integer_to_binary(TimestampInt), <>. +-spec add_path_prefix(t(), binary()) -> + t(). +add_path_prefix(?T{path=Path}=T, <>) -> + 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 %% ============================================================================ @@ -251,9 +265,3 @@ cons(Path, Value, Timestamp) -> , 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}]).