+-spec ets_to_msgs(beam_stats_ets:t()) ->
+ [statsd_msg()].
+ets_to_msgs(PerTableStats) ->
+ NestedMsgs = lists:map(fun ets_table_to_msgs/1, PerTableStats),
+ lists:append(NestedMsgs).
+
+-spec ets_table_to_msgs(beam_stats_ets_table:t()) ->
+ [statsd_msg()].
+ets_table_to_msgs(#beam_stats_ets_table
+ { id = ID
+ , name = Name
+ , size = Size
+ , memory = Memory
+ }
+) ->
+ IDBin = beam_stats_ets_table:id_to_bin(ID),
+ NameBin = atom_to_binary(Name, latin1),
+ NameAndID = <<NameBin/binary, ".", IDBin/binary>>,
+ SizeMsg =
+ #statsd_msg
+ { name = <<"ets_table.size.", NameAndID/binary>>
+ , value = Size
+ , type = gauge
+ },
+ MemoryMsg =
+ #statsd_msg
+ { name = <<"ets_table.memory.", NameAndID/binary>>
+ , value = Memory
+ , type = gauge
+ },
+ [SizeMsg, MemoryMsg].
+