Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enable setting batch_len from settings.

  • Loading branch information...
commit cad663f13cb059d46fac784330d87ceafc519ba7 1 parent 76c614f
James Socol authored
Showing with 6 additions and 2 deletions.
  1. +2 −0  docs/configure.rst
  2. +4 −2 statsd/__init__.py
View
2  docs/configure.rst
@@ -69,6 +69,7 @@ Here are the settings and their defaults::
STATSD_HOST = 'localhost'
STATSD_PORT = 8125
STATSD_PREFIX = None
+ STATSD_BATCH_LEN = 1
You can use the default ``StatsClient`` simply::
@@ -92,6 +93,7 @@ You can set these variables in the environment::
STATSD_HOST
STATSD_PORT
STATSD_PREFIX
+ STATSD_BATCH_LEN
and then in your Python application, you can simply do::
View
6 statsd/__init__.py
@@ -23,7 +23,8 @@
host = getattr(settings, 'STATSD_HOST', 'localhost')
port = getattr(settings, 'STATSD_PORT', 8125)
prefix = getattr(settings, 'STATSD_PREFIX', None)
- statsd = StatsClient(host, port, prefix)
+ batch_len = getattr(settings, 'STATSD_BATCH_LEN', 1)
+ statsd = StatsClient(host, port, prefix, batch_len)
except (socket.error, socket.gaierror, ImportError):
pass
elif 'STATSD_HOST' in os.environ:
@@ -31,6 +32,7 @@
host = os.environ['STATSD_HOST']
port = int(os.environ['STATSD_PORT'])
prefix = os.environ.get('STATSD_PREFIX')
- statsd = StatsClient(host, port, prefix)
+ batch_len = int(os.environ.get('STATSD_BATCH_LEN', 1))
+ statsd = StatsClient(host, port, prefix, batch_len)
except (socket.error, socket.gaierror, KeyError):
pass

0 comments on commit cad663f

Please sign in to comment.
Something went wrong with that request. Please try again.