Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Enable setting batch_len from settings.

  • Loading branch information...
commit cad663f13cb059d46fac784330d87ceafc519ba7 1 parent 76c614f
James Socol authored

Showing 2 changed files with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. +2 0  docs/configure.rst
  2. +4 2 statsd/__init__.py
2  docs/configure.rst
Source Rendered
@@ -69,6 +69,7 @@ Here are the settings and their defaults::
69 69 STATSD_HOST = 'localhost'
70 70 STATSD_PORT = 8125
71 71 STATSD_PREFIX = None
  72 + STATSD_BATCH_LEN = 1
72 73
73 74 You can use the default ``StatsClient`` simply::
74 75
@@ -92,6 +93,7 @@ You can set these variables in the environment::
92 93 STATSD_HOST
93 94 STATSD_PORT
94 95 STATSD_PREFIX
  96 + STATSD_BATCH_LEN
95 97
96 98 and then in your Python application, you can simply do::
97 99
6 statsd/__init__.py
@@ -23,7 +23,8 @@
23 23 host = getattr(settings, 'STATSD_HOST', 'localhost')
24 24 port = getattr(settings, 'STATSD_PORT', 8125)
25 25 prefix = getattr(settings, 'STATSD_PREFIX', None)
26   - statsd = StatsClient(host, port, prefix)
  26 + batch_len = getattr(settings, 'STATSD_BATCH_LEN', 1)
  27 + statsd = StatsClient(host, port, prefix, batch_len)
27 28 except (socket.error, socket.gaierror, ImportError):
28 29 pass
29 30 elif 'STATSD_HOST' in os.environ:
@@ -31,6 +32,7 @@
31 32 host = os.environ['STATSD_HOST']
32 33 port = int(os.environ['STATSD_PORT'])
33 34 prefix = os.environ.get('STATSD_PREFIX')
34   - statsd = StatsClient(host, port, prefix)
  35 + batch_len = int(os.environ.get('STATSD_BATCH_LEN', 1))
  36 + statsd = StatsClient(host, port, prefix, batch_len)
35 37 except (socket.error, socket.gaierror, KeyError):
36 38 pass

0 comments on commit cad663f

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