Include the metric type in it's name. 0.1.0
authorSiraaj Khandkar <siraaj@khandkar.net>
Sun, 23 Aug 2015 22:04:06 +0000 (18:04 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Sun, 23 Aug 2015 22:04:06 +0000 (18:04 -0400)
src/beam_stats.app.src
src/beam_stats_consumer_csv.erl
src/beam_stats_consumer_graphite.erl
src/beam_stats_consumer_statsd.erl
test/beam_stats_consumer_statsd_SUITE.erl

index 9f5c428..e6b3ab7 100644 (file)
@@ -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
index c9d2785..6b27106 100644 (file)
@@ -101,9 +101,9 @@ beam_stats_to_bin(#beam_stats
 ) ->
     <<TimestampBin/binary>> = timestamp_to_bin(Timestamp),
     <<NodeIDBin/binary>> = 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(<<NodeID/binary>>, <<TimestampBin/binary>>) ->
+make_pair_to_bin(<<NodeID/binary>>, <<TimestampBin/binary>>, <<Type/binary>>) ->
     fun ({<<K/binary>>, <<V/binary>>}) ->
         << TimestampBin/binary
          , "|"
          , NodeID/binary
          , "|"
+         , Type/binary
+         , "|"
          , K/binary
          , "|"
          , V/binary
index e788d29..6e0d5dd 100644 (file)
@@ -123,9 +123,9 @@ beam_stats_to_bin(#beam_stats
     TimestampInt = timestamp_to_integer(Timestamp),
     TimestampBin = integer_to_binary(TimestampInt),
     <<NodeIDBin/binary>> = 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(<<NodeID/binary>>, <<TimestampBin/binary>>) ->
+make_pair_to_bin(<<NodeID/binary>>, <<TimestampBin/binary>>, <<Type/binary>>) ->
     fun ({<<K/binary>>, <<V/binary>>}) ->
         << ?GRAPHITE_PATH_PREFIX
          , "."
          , NodeID/binary
          , "."
+         , Type/binary
+         , "."
          , K/binary
          , " "
          , V/binary
index 70ed8dc..f5828bf 100644 (file)
@@ -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
     }.
index f5fbc0b..9c7e175 100644 (file)
@@ -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.
This page took 0.033113 seconds and 4 git commands to generate.