diff options
author | Anders Svensson <[email protected]> | 2013-03-03 23:44:57 +0100 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2013-03-04 02:11:03 +0100 |
commit | 3e77e534655b7197a0999a68480fb524b8cb0273 (patch) | |
tree | fc66b0c7bbc6a5114b382276ca98fb29321fa53b /lib/diameter/test | |
parent | a84278f0ddc2a5431168294b1646aa0703ad03a3 (diff) | |
download | otp-3e77e534655b7197a0999a68480fb524b8cb0273.tar.gz otp-3e77e534655b7197a0999a68480fb524b8cb0273.tar.bz2 otp-3e77e534655b7197a0999a68480fb524b8cb0273.zip |
Rework stats to avoid concurrent read and write
Counters read by diameter:service_info(SvcName, transport) can be
selected at the same time as the diameter_stats server is folding them
into another key, possibly resulting in inaccurate values. Have
diameter_stats select from the server process to avoid this and add
diameter_stats:sum/1 to sum values from all contributors on a given
term.
Diffstat (limited to 'lib/diameter/test')
-rw-r--r-- | lib/diameter/test/diameter_stats_SUITE.erl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/diameter/test/diameter_stats_SUITE.erl b/lib/diameter/test/diameter_stats_SUITE.erl index af52afb59c..76ff764671 100644 --- a/lib/diameter/test/diameter_stats_SUITE.erl +++ b/lib/diameter/test/diameter_stats_SUITE.erl @@ -33,6 +33,7 @@ -export([reg/1, incr/1, read/1, + sum/1, flush/1]). -define(stat, diameter_stats). @@ -53,6 +54,7 @@ tc() -> [reg, incr, read, + sum, flush]. init_per_suite(Config) -> @@ -98,6 +100,23 @@ read(_) -> [] = ?stat:read([make_ref()]), ?stat:flush([self(), Ref, make_ref()]). +sum(_) -> + Ref = make_ref(), + C1 = {a,b}, + C2 = {b,a}, + true = ?stat:reg(Ref), + 1 = ?stat:incr(C1), + 1 = ?stat:incr(C2), + 2 = ?stat:incr(C2), + 7 = ?stat:incr(C1, Ref, 7), + [{Ref, [{C1,8}, {C2,2}]}] + = ?stat:sum([Ref, make_ref()]), + Self = self(), + [{Self, [{C1,1}, {C2,2}]}] + = ?stat:sum([self()]), + [{Ref, [{C1,7}]}, {Self, [{C1,1}, {C2,2}]}] + = lists:sort(?stat:flush([self(), Ref])). + flush(_) -> Ref = make_ref(), Ctr = '_', |