From: Siraaj Khandkar Date: Sun, 23 Aug 2015 22:04:06 +0000 (-0400) Subject: Include the metric type in it's name. X-Git-Tag: 0.1.0^0 X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=101874c36980f5c738575c0143ae673c0797b6d4;p=beam_stats.git Include the metric type in it's name. --- diff --git a/src/beam_stats.app.src b/src/beam_stats.app.src index 9f5c428..e6b3ab7 100644 --- a/src/beam_stats.app.src +++ b/src/beam_stats.app.src @@ -1,7 +1,7 @@ {application, beam_stats, [ {description, "Periodic VM stats production and consumption."}, - {vsn, "0.0.1"}, + {vsn, "0.1.0"}, {registered, []}, {applications, [ kernel diff --git a/src/beam_stats_consumer_csv.erl b/src/beam_stats_consumer_csv.erl index c9d2785..6b27106 100644 --- a/src/beam_stats_consumer_csv.erl +++ b/src/beam_stats_consumer_csv.erl @@ -101,9 +101,9 @@ beam_stats_to_bin(#beam_stats ) -> <> = timestamp_to_bin(Timestamp), <> = node_id_to_bin(NodeID), - PairToBin = make_pair_to_bin(NodeIDBin, TimestampBin), + MemoryPairToBin = make_pair_to_bin(NodeIDBin, TimestampBin, <<"memory">>), MemoryBinPairs = lists:map(fun atom_int_to_bin_bin/1, Memory), - MemoryBins = lists:map(PairToBin, MemoryBinPairs), + MemoryBins = lists:map(MemoryPairToBin, MemoryBinPairs), AllBins = [ MemoryBins ], @@ -131,14 +131,16 @@ timestamp_to_float({ComponentMega, ComponentWhole, ComponentMicro}) -> TotalMicroSeconds = (TotalWholeSeconds * OneMillion) + ComponentMicro, TotalMicroSeconds / OneMillion. --spec make_pair_to_bin(binary(), binary()) -> +-spec make_pair_to_bin(binary(), binary(), binary()) -> fun(({binary(), binary()}) -> binary()). -make_pair_to_bin(<>, <>) -> +make_pair_to_bin(<>, <>, <>) -> fun ({<>, <>}) -> << TimestampBin/binary , "|" , NodeID/binary , "|" + , Type/binary + , "|" , K/binary , "|" , V/binary diff --git a/src/beam_stats_consumer_graphite.erl b/src/beam_stats_consumer_graphite.erl index e788d29..6e0d5dd 100644 --- a/src/beam_stats_consumer_graphite.erl +++ b/src/beam_stats_consumer_graphite.erl @@ -123,9 +123,9 @@ beam_stats_to_bin(#beam_stats TimestampInt = timestamp_to_integer(Timestamp), TimestampBin = integer_to_binary(TimestampInt), <> = node_id_to_bin(NodeID), - PairToBin = make_pair_to_bin(NodeIDBin, TimestampBin), + MemoryPairToBin = make_pair_to_bin(NodeIDBin, TimestampBin, <<"memory">>), MemoryBinPairs = lists:map(fun atom_int_to_bin_bin/1, Memory), - MemoryBins = lists:map(PairToBin, MemoryBinPairs), + MemoryBins = lists:map(MemoryPairToBin, MemoryBinPairs), AllBins = [ MemoryBins ], @@ -136,14 +136,16 @@ beam_stats_to_bin(#beam_stats timestamp_to_integer({Megaseconds, Seconds, _}) -> Megaseconds * 1000000 + Seconds. --spec make_pair_to_bin(binary(), binary()) -> +-spec make_pair_to_bin(binary(), binary(), binary()) -> fun(({binary(), binary()}) -> binary()). -make_pair_to_bin(<>, <>) -> +make_pair_to_bin(<>, <>, <>) -> fun ({<>, <>}) -> << ?GRAPHITE_PATH_PREFIX , "." , NodeID/binary , "." + , Type/binary + , "." , K/binary , " " , V/binary diff --git a/src/beam_stats_consumer_statsd.erl b/src/beam_stats_consumer_statsd.erl index 70ed8dc..f5828bf 100644 --- a/src/beam_stats_consumer_statsd.erl +++ b/src/beam_stats_consumer_statsd.erl @@ -157,8 +157,9 @@ memory_to_msgs(Memory) -> -spec memory_component_to_statsd_msg({atom(), non_neg_integer()}) -> statsd_msg(). memory_component_to_statsd_msg({MemType, MemSize}) when MemSize >= 0 -> + MemTypeBin = atom_to_binary(MemType, latin1), #statsd_msg - { name = atom_to_binary(MemType, latin1) + { name = <<"memory.", MemTypeBin/binary>> , value = MemSize , type = gauge }. diff --git a/test/beam_stats_consumer_statsd_SUITE.erl b/test/beam_stats_consumer_statsd_SUITE.erl index f5fbc0b..9c7e175 100644 --- a/test/beam_stats_consumer_statsd_SUITE.erl +++ b/test/beam_stats_consumer_statsd_SUITE.erl @@ -48,4 +48,4 @@ t_send(_Cfg) -> ResultOfReceive = gen_udp:recv(ServerSocket, 0), ok = gen_udp:close(ServerSocket), {ok, {_, _, Data}} = ResultOfReceive, - <<"beam_stats.node_foo_host_bar.mem_type_foo:1|g\n">> = Data. + <<"beam_stats.node_foo_host_bar.memory.mem_type_foo:1|g\n">> = Data.