Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Document batch_len argument.

  • Loading branch information...
commit 76c614fa6714573f22bee59e30f0be2ac6d17099 1 parent eb7ad47
James Socol authored
Showing with 33 additions and 3 deletions.
  1. +8 −1 docs/configure.rst
  2. +25 −2 docs/reference.rst
9 docs/configure.rst
@@ -26,7 +26,8 @@ their defaults, are::
statsd = StatsClient(host='localhost',
- prefix=None)
+ prefix=None,
+ batch_len=1)
``host`` is the host running the statsd server. It will support any kind of
name or IP address you might use.
@@ -50,6 +51,12 @@ will produce two different stats, ``foo.baz`` and ``bar.baz``. Without the
``prefix`` argument, or with the same ``prefix``, two ``StatsClient`` instances
will update the same stats.
+``batch_len`` tells the client how many stats to batch before sending to the
+statsd_ server. By default, this is ``1``, i.e. "automatically send every
+stat." If it is set to ``n``, the client will only send data to the server
+after every ``n`` other stats calls. It can be flushed to the server by calling
+``StatsClient.flush()`` (see :ref:`flush`).
In Django
27 docs/reference.rst
@@ -21,7 +21,7 @@ server supports.
- StatsClient(host='localhost', port=8125, prefix=None)
+ StatsClient(host='localhost', port=8125, prefix=None, batch_len=1)
Create a new ``StatsClient`` instance with the appropriate connection and
prefix information.
@@ -31,7 +31,10 @@ prefix information.
* ``port``: the port of the statsd server.
* ``prefix``: a prefix to distinguish and group stats from an application or
- environment
+ environment.
+* ``batch_len``: how many stats to batch before flushing to the statsd_ server.
+ See :ref:`flush`.
.. _incr:
@@ -150,5 +153,25 @@ Set a :ref:`gauge <gauge-type>` value.
+.. _flush:
+ StatsClient().flush()
+Flush batched stats data to the statsd_ server.
+.. note::
+ If you create a StatsClient instance with a ``batch_len`` greater than 1,
+ you should find a way to call ``flush`` at the end of whatever your
+ application is doing, because the client will only send every time the
+ number of stats is zero modulo ``batch_len``, which may introduce a systemic
+ bias to your stats.
.. _statsd:
.. _0ed78be:
Please sign in to comment.
Something went wrong with that request. Please try again.