Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds some statistics gathering to the riakc client. In our applications we've found that the server side stats didn't provide us with a full picture as NW latency is a significant part of the whole request time.
stats_demo_test gives a quick sanity check of the functionality but here's an example use-case with a snippet of output data from our live system (sensitive info blanked out) to see its real value:
Assuming you have a variable PidList with the pids of all the clients in the system, set the stats level to 2 with:
lists:foreach(fun(Pid) -> riakc_pb_socket:stats_change_level(Pid, 2) end, PidList).
Then after some time grab all the collected stats with:
FullStat = lists:foldl(fun(Pid,StatAcc) -> riakc_stats:merge(StatAcc,riakc_pb_socket:stats_peek(Pid)) end, riakc_pb_socket:stats_peek(hd(PidList)), tl(PidList)).
Then format the raw stats data with:
riakc_stats:print(FullStat).
Riak Connection Stats
connections established: 200
stat monitoring period: 260 s
2 put requests on bucket: <<"bucket1">> timed out while being serviced, timeout: 500.
on 6 occassions the queue was 1 requests long when new requests were added.
1 get requests on bucket: <<"bucket2">> timed out while being serviced, timeout: 500.
24454 put operations on bucket: <<"bucket1">>
with timeout: 500
average service time: 15 ms
7009 between 7 ms and 10 ms
16574 between 10 ms and 20 ms
535 between 20 ms and 40 ms
192 between 40 ms and 70 ms
39 between 70 ms and 100 ms
30 between 100 ms and 200 ms
74 between 200 ms and 400 ms
1 between 400 ms and 700 ms
47329 get operations on bucket: <<"bucket1">>
with timeout: 500
average service time: 13 ms
20718 between 7 ms and 10 ms
25595 between 10 ms and 20 ms
658 between 20 ms and 40 ms
179 between 40 ms and 70 ms
44 between 70 ms and 100 ms
48 between 100 ms and 200 ms
86 between 200 ms and 400 ms
1 between 400 ms and 700 ms
data sent: 19 MB
packets: 119449
average packet size: 165 B
94679 between 20 B and 40 B
274 between 40 B and 70 B
22 between 100 B and 200 B
39 between 200 B and 400 B
17495 between 400 B and 700 B
2009 between 700 B and 1 KB
4794 between 1 KB and 2 KB
83 between 2 KB and 4 KB
54 between 4 KB and 7 KB
data received: 69 MB
packets: 119442
average packet size: 580 B
24792 between 0 B and 1 B
196 between 100 B and 200 B
2620 between 200 B and 400 B
67329 between 400 B and 700 B
3852 between 700 B and 1 KB
20325 between 1 KB and 2 KB
215 between 2 KB and 4 KB
113 between 4 KB and 7 KB
reconnections: 3
average reconnect time: 914 us
2 between 700 us and 1 ms
1 between 1 ms and 2 ms
6 requests got queued with timeout: 1000
average queueing time: 65 ms
1 between 10 ms and 20 ms
2 between 20 ms and 40 ms
1 between 70 ms and 100 ms
2 between 100 ms and 200 ms