home
/
code
/
beam_stats.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b4e2333
)
Track context_switches delta.
0.3.0
author
Siraaj Khandkar
<siraaj@khandkar.net>
Tue, 25 Aug 2015 00:06:24 +0000
(20:06 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Tue, 25 Aug 2015 00:06:24 +0000
(20:06 -0400)
include/beam_stats.hrl
patch
|
blob
|
blame
|
history
src/beam_stats.app.src
patch
|
blob
|
blame
|
history
src/beam_stats_consumer_statsd.erl
patch
|
blob
|
blame
|
history
src/beam_stats_state.erl
patch
|
blob
|
blame
|
history
test/beam_stats_consumer_statsd_SUITE.erl
patch
|
blob
|
blame
|
history
diff --git
a/include/beam_stats.hrl
b/include/beam_stats.hrl
index
db26c6d
..
ae0b48a
100644
(file)
--- a/
include/beam_stats.hrl
+++ b/
include/beam_stats.hrl
@@
-4,6
+4,7
@@
, memory :: [{atom(), non_neg_integer()}]
, io_bytes_in :: non_neg_integer()
, io_bytes_out :: non_neg_integer()
, memory :: [{atom(), non_neg_integer()}]
, io_bytes_in :: non_neg_integer()
, io_bytes_out :: non_neg_integer()
+ , context_switches :: non_neg_integer()
%, statistics :: [{atom() , term()}]
%, system :: [{atom() , term()}]
%, process :: [{atom() , term()}]
%, statistics :: [{atom() , term()}]
%, system :: [{atom() , term()}]
%, process :: [{atom() , term()}]
diff --git
a/src/beam_stats.app.src
b/src/beam_stats.app.src
index
489c32c
..
00697fc
100644
(file)
--- 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."},
{application, beam_stats,
[
{description, "Periodic VM stats production and consumption."},
- {vsn, "0.
2
.0"},
+ {vsn, "0.
3
.0"},
{registered, []},
{applications,
[ kernel
{registered, []},
{applications,
[ kernel
diff --git
a/src/beam_stats_consumer_statsd.erl
b/src/beam_stats_consumer_statsd.erl
index
c23ead1
..
5b2f818
100644
(file)
--- a/
src/beam_stats_consumer_statsd.erl
+++ b/
src/beam_stats_consumer_statsd.erl
@@
-144,17
+144,28
@@
beam_stats_to_bins(#beam_stats
, memory = Memory
, io_bytes_in = IOBytesIn
, io_bytes_out = IOBytesOut
, memory = Memory
, io_bytes_in = IOBytesIn
, io_bytes_out = IOBytesOut
+ , context_switches = ContextSwitches
}
) ->
NodeIDBin = node_id_to_bin(NodeID),
Msgs1 =
[ io_bytes_in_to_msg(IOBytesIn)
, io_bytes_out_to_msg(IOBytesOut)
}
) ->
NodeIDBin = node_id_to_bin(NodeID),
Msgs1 =
[ io_bytes_in_to_msg(IOBytesIn)
, io_bytes_out_to_msg(IOBytesOut)
+ , context_switches_to_msg(ContextSwitches)
| memory_to_msgs(Memory)
],
Msgs2 = [statsd_msg_add_name_prefix(M, NodeIDBin) || M <- Msgs1],
[statsd_msg_to_bin(M) || M <- Msgs2].
| memory_to_msgs(Memory)
],
Msgs2 = [statsd_msg_add_name_prefix(M, NodeIDBin) || M <- Msgs1],
[statsd_msg_to_bin(M) || M <- Msgs2].
+-spec context_switches_to_msg(non_neg_integer()) ->
+ statsd_msg().
+context_switches_to_msg(ContextSwitches) ->
+ #statsd_msg
+ { name = <<"context_switches">>
+ , value = ContextSwitches
+ , type = gauge
+ }.
+
-spec io_bytes_in_to_msg(non_neg_integer()) ->
statsd_msg().
io_bytes_in_to_msg(IOBytesIn) ->
-spec io_bytes_in_to_msg(non_neg_integer()) ->
statsd_msg().
io_bytes_in_to_msg(IOBytesIn) ->
diff --git
a/src/beam_stats_state.erl
b/src/beam_stats_state.erl
index
552b5b1
..
17f9c90
100644
(file)
--- a/
src/beam_stats_state.erl
+++ b/
src/beam_stats_state.erl
@@
-16,10
+16,14
@@
{ timestamp :: erlang:timestamp()
, node_id :: atom()
, memory :: [{atom(), non_neg_integer()}]
{ timestamp :: erlang:timestamp()
, node_id :: atom()
, memory :: [{atom(), non_neg_integer()}]
+
, previous_io_bytes_in :: non_neg_integer()
, previous_io_bytes_out :: non_neg_integer()
, current_io_bytes_in :: non_neg_integer()
, current_io_bytes_out :: non_neg_integer()
, previous_io_bytes_in :: non_neg_integer()
, previous_io_bytes_out :: non_neg_integer()
, current_io_bytes_in :: non_neg_integer()
, current_io_bytes_out :: non_neg_integer()
+
+ , previous_context_switches :: non_neg_integer()
+ , current_context_switches :: non_neg_integer()
}).
-define(T, #?MODULE).
}).
-define(T, #?MODULE).
@@
-33,6
+37,7
@@
new() ->
{ {input , CurrentIOBytesIn}
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
{ {input , CurrentIOBytesIn}
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
+ {CurrentContextSwitches, 0} = erlang:statistics(context_switches),
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
@@
-41,6
+46,8
@@
new() ->
, previous_io_bytes_out = 0
, current_io_bytes_in = CurrentIOBytesIn
, current_io_bytes_out = CurrentIOBytesOut
, previous_io_bytes_out = 0
, current_io_bytes_in = CurrentIOBytesIn
, current_io_bytes_out = CurrentIOBytesOut
+ , previous_context_switches = 0
+ , current_context_switches = CurrentContextSwitches
}.
-spec update(t()) ->
}.
-spec update(t()) ->
@@
-48,11
+55,13
@@
new() ->
update(?T
{ previous_io_bytes_in = PreviousIOBytesIn
, previous_io_bytes_out = PreviousIOBytesOut
update(?T
{ previous_io_bytes_in = PreviousIOBytesIn
, previous_io_bytes_out = PreviousIOBytesOut
+ , previous_context_switches = PreviousContextSwitches
}
) ->
{ {input , CurrentIOBytesIn}
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
}
) ->
{ {input , CurrentIOBytesIn}
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
+ {CurrentContextSwitches, 0} = erlang:statistics(context_switches),
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
@@
-61,6
+70,8
@@
update(?T
, previous_io_bytes_out = PreviousIOBytesOut
, current_io_bytes_in = CurrentIOBytesIn
, current_io_bytes_out = CurrentIOBytesOut
, previous_io_bytes_out = PreviousIOBytesOut
, current_io_bytes_in = CurrentIOBytesIn
, current_io_bytes_out = CurrentIOBytesOut
+ , previous_context_switches = PreviousContextSwitches
+ , current_context_switches = CurrentContextSwitches
}.
-spec export(t()) ->
}.
-spec export(t()) ->
@@
-74,6
+85,8
@@
export(
, previous_io_bytes_out = PreviousIOBytesOut
, current_io_bytes_in = CurrentIOBytesIn
, current_io_bytes_out = CurrentIOBytesOut
, previous_io_bytes_out = PreviousIOBytesOut
, current_io_bytes_in = CurrentIOBytesIn
, current_io_bytes_out = CurrentIOBytesOut
+ , previous_context_switches = PreviousContextSwitches
+ , current_context_switches = CurrentContextSwitches
}
) ->
#beam_stats
}
) ->
#beam_stats
@@
-82,4
+95,5
@@
export(
, memory = Memory
, io_bytes_in = CurrentIOBytesIn - PreviousIOBytesIn
, io_bytes_out = CurrentIOBytesOut - PreviousIOBytesOut
, memory = Memory
, io_bytes_in = CurrentIOBytesIn - PreviousIOBytesIn
, io_bytes_out = CurrentIOBytesOut - PreviousIOBytesOut
+ , context_switches = CurrentContextSwitches - PreviousContextSwitches
}.
}.
diff --git
a/test/beam_stats_consumer_statsd_SUITE.erl
b/test/beam_stats_consumer_statsd_SUITE.erl
index
161eac1
..
87f5dd3
100644
(file)
--- a/
test/beam_stats_consumer_statsd_SUITE.erl
+++ b/
test/beam_stats_consumer_statsd_SUITE.erl
@@
-39,6
+39,7
@@
t_send(_Cfg) ->
, memory = [{mem_type_foo, 1}]
, io_bytes_in = 3
, io_bytes_out = 7
, memory = [{mem_type_foo, 1}]
, io_bytes_in = 3
, io_bytes_out = 7
+ , context_switches = 5
},
ServerPort = 8125,
{ok, ServerSocket} = gen_udp:open(ServerPort, [binary, {active, false}]),
},
ServerPort = 8125,
{ok, ServerSocket} = gen_udp:open(ServerPort, [binary, {active, false}]),
@@
-52,5
+53,6
@@
t_send(_Cfg) ->
{ok, {_, _, Data}} = ResultOfReceive,
<< "beam_stats.node_foo_host_bar.io.bytes_in:3|g\n"
, "beam_stats.node_foo_host_bar.io.bytes_out:7|g\n"
{ok, {_, _, Data}} = ResultOfReceive,
<< "beam_stats.node_foo_host_bar.io.bytes_in:3|g\n"
, "beam_stats.node_foo_host_bar.io.bytes_out:7|g\n"
+ , "beam_stats.node_foo_host_bar.context_switches:5|g\n"
, "beam_stats.node_foo_host_bar.memory.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.02524 seconds
and
4
git commands to generate.