Update to use couch_stats
diff --git a/priv/stats_descriptions.cfg b/priv/stats_descriptions.cfg
new file mode 100644
index 0000000..93c29d9
--- /dev/null
+++ b/priv/stats_descriptions.cfg
@@ -0,0 +1,24 @@
+{[rexi, buffered], [
+    {type, counter},
+    {desc, <<"number of rexi messages buffered">>}
+]}.
+{[rexi, down], [
+    {type, counter},
+    {desc, <<"number of rexi_DOWN messages handled">>}
+]}.
+{[rexi, dropped], [
+    {type, counter},
+    {desc, <<"number of rexi messages dropped from buffers">>}
+]}.
+{[rexi, streams, timeout, init_stream], [
+    {type, counter},
+    {desc, <<"number of rexi stream initialization timeouts">>}
+]}.
+{[rexi, streams, timeout, stream], [
+    {type, counter},
+    {desc, <<"number of rexi stream timeouts">>}
+]}.
+{[rexi, streams, timeout, wait_for_ack], [
+    {type, counter},
+    {desc, <<"number of rexi stream timeouts while waiting for acks">>}
+]}.
diff --git a/src/rexi.app.src b/src/rexi.app.src
index 639e9dc..efe128c 100644
--- a/src/rexi.app.src
+++ b/src/rexi.app.src
@@ -31,6 +31,7 @@
         kernel,
         stdlib,
         couch_log,
+        couch_stats,
         config
     ]},
     {mod, {rexi_app,[]}}
diff --git a/src/rexi.erl b/src/rexi.erl
index 69fbd77..fea4d64 100644
--- a/src/rexi.erl
+++ b/src/rexi.erl
@@ -134,6 +134,9 @@
         rexi_STREAM_CANCEL ->
             exit(normal);
         timeout ->
+            couch_stats:increment_counter(
+                [rexi, streams, timeout, init_stream]
+            ),
             exit(timeout);
         Else ->
             exit({invalid_stream_message, Else})
@@ -179,6 +182,7 @@
             erlang:send(Caller, {Ref, self(), Msg}),
             ok
     catch throw:timeout ->
+        couch_stats:increment_counter([rexi, streams, timeout, stream]),
         exit(timeout)
     end.
 
@@ -205,6 +209,7 @@
             erlang:send(Caller, {Ref, self(), Msg}),
             ok
     catch throw:timeout ->
+        couch_stats:increment_counter([rexi, streams, timeout, stream]),
         exit(timeout)
     end.
 
@@ -267,6 +272,7 @@
     receive
         {rexi_ack, N} -> drain_acks(Count-N)
     after Timeout ->
+        couch_stats:increment_counter([rexi, streams, timeout, wait_for_ack]),
         throw(timeout)
     end.
 
diff --git a/src/rexi_buffer.erl b/src/rexi_buffer.erl
index 2be2322..d16dc8b 100644
--- a/src/rexi_buffer.erl
+++ b/src/rexi_buffer.erl
@@ -50,9 +50,11 @@
     {reply, State#state.count, State, 0}.
 
 handle_cast({deliver, Dest, Msg}, #state{buffer = Q, count = C} = State) ->
+    couch_stats:increment_counter([rexi, buffered]),
     Q2 = queue:in({Dest, Msg}, Q),
     case should_drop(State) of
     true ->
+        couch_stats:increment_counter([rexi, dropped]),
             {noreply, State#state{buffer = queue:drop(Q2)}, 0};
     false ->
             {noreply, State#state{buffer = Q2, count = C+1}, 0}
diff --git a/src/rexi_monitor.erl b/src/rexi_monitor.erl
index 7be3f0a..f143ead 100644
--- a/src/rexi_monitor.erl
+++ b/src/rexi_monitor.erl
@@ -40,6 +40,7 @@
 %% internal functions %%
 
 notify_parent(Parent, Pid, Reason) ->
+    couch_stats:increment_counter([rexi, down]),
     erlang:send(Parent, {rexi_DOWN, self(), Pid, Reason}).
 
 should_monitor(Pid, Nodes) when is_pid(Pid) ->