home
/
code
/
beam_stats.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #12 from ibnfirnas/factor-and-abstract-graphite-msg
[beam_stats.git]
/
src
/
beam_stats_msg_graphite.erl
diff --git
a/src/beam_stats_msg_graphite.erl
b/src/beam_stats_msg_graphite.erl
index
6883ff1
..
de18c0d
100644
(file)
--- a/
src/beam_stats_msg_graphite.erl
+++ b/
src/beam_stats_msg_graphite.erl
@@
-13,8
+13,11
@@
-export(
[ of_beam_stats/1
-export(
[ of_beam_stats/1
+ , of_beam_stats/2
, to_bin/1
, path_to_bin/1
, to_bin/1
, path_to_bin/1
+ , add_path_prefix/2
+ , node_id_to_bin/1
]).
-define(T, #?MODULE).
]).
-define(T, #?MODULE).
@@
-38,7
+41,6
@@
of_beam_stats(#beam_stats
{ timestamp = Timestamp
, node_id = _
, memory = Memory
{ timestamp = Timestamp
, node_id = _
, memory = Memory
- % TODO: Handle the rest of data points
, io_bytes_in = IOBytesIn
, io_bytes_out = IOBytesOut
, context_switches = ContextSwitches
, io_bytes_in = IOBytesIn
, io_bytes_out = IOBytesOut
, context_switches = ContextSwitches
@@
-76,11
+78,22
@@
to_bin(
TimestampBin = integer_to_binary(TimestampInt),
<<PathBin/binary, " ", ValueBin/binary, " ", TimestampBin/binary>>.
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 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
%% ============================================================================
%% ============================================================================
%% Helpers
%% ============================================================================
@@
-108,7
+121,7
@@
of_memory(Memory, <<NodeID/binary>>, Timestamp) ->
end,
lists:map(ComponentToMessage, Memory).
end,
lists:map(ComponentToMessage, Memory).
--spec of_ets(beam_stats_ets
_table
:t(), binary(), erlang:timestamp()) ->
+-spec of_ets(beam_stats_ets:t(), binary(), erlang:timestamp()) ->
[t()].
of_ets(PerTableStats, <<NodeID/binary>>, Timestamp) ->
OfEtsTable = fun (Table) -> of_ets_table(Table, NodeID, Timestamp) end,
[t()].
of_ets(PerTableStats, <<NodeID/binary>>, Timestamp) ->
OfEtsTable = fun (Table) -> of_ets_table(Table, NodeID, Timestamp) end,
@@
-251,9
+264,3
@@
cons(Path, Value, Timestamp) ->
, value = Value
, timestamp = 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}]).
This page took
0.032091 seconds
and
4
git commands to generate.