diff --git a/README.rst b/README.rst index 1c5b299..7ec521e 100644 --- a/README.rst +++ b/README.rst @@ -28,8 +28,13 @@ from using `statsd`_ to `InfluxDB`_ is simply a matter of switch from the ``metrics.StatsdMixin`` to the ``metrics.InfluxDBMixin``. The mix-in is configured through the ``tornado.web.Application`` settings -property using a key defined by the specific mix-in. The following snippet -configures the StatsD mix-in from common environment variables: +property using a key defined by the specific mix-in. + +Statsd Mixin +------------ + +The following snippet configures the StatsD mix-in from common environment +variables: .. code-block:: python @@ -50,6 +55,46 @@ configures the StatsD mix-in from common environment variables: # insert handlers here ], **settings) +:namespace: The namespace for the measurements +:host: The Statsd host +:port: The Statsd port + +InfluxDB Mixin +-------------- + +The following snippet configures the InfluxDB mix-in from common environment +variables: + +.. code-block:: python + + import os + + from sprockets.mixins import metrics + from tornado import web + + def make_application(): + settings = { + metrics.InfluxDBMixin.SETTINGS_KEY: { + 'measurement': 'my-application', + 'database': 'services', + 'write_url': 'http://{}:{}/write'.format( + os.environ.get('INFLUX_HOST', '127.0.0.1'), + os.environ.get('INFLUX_PORT', 8086)), + 'max_buffer_time': 3, + 'max_buffer_length': 100 + } + } + return web.Application([ + # insert handlers here + ], **settings) + +:measurement: The InfluxDB measurement name +:database: The InfluxDB database to write measurements into +:write_url: the InfluxDB write URL to send HTTP requests to +:max_buffer_time: The maximum elasped time measurements should remain in + buffer before writing to InfluxDB. +:max_buffer_length: The maximum number of measurements to + buffer before writing to InfluxDB. Development Quickstart ---------------------- diff --git a/docs/history.rst b/docs/history.rst index b34f31b..4aa609e 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -3,6 +3,10 @@ Release History =============== +`1.1.0`_ (9-Mar-2016) +--------------------- +- Update InfluxDB mixin to buffer measurements across requests based on a max time and/or length. + `1.0.1`_ (1-Feb-2016) --------------------- - Fix packaging woes. @@ -20,7 +24,8 @@ Release History - Add :class:`sprockets.mixins.metrics.InfluxDBMixin` - Add :class:`sprockets.mixins.metrics.influxdb.InfluxDBConnection` -.. _Next Release: https://github.com/sprockets/sprockets.mixins.metrics/compare/1.0.1...master -.. _1.0.0: https://github.com/sprockets/sprockets.mixins.metrics/compare/1.0.0...1.0.0 +.. _Next Release: https://github.com/sprockets/sprockets.mixins.metrics/compare/1.1.0...master +.. _1.1.0: https://github.com/sprockets/sprockets.mixins.metrics/compare/1.0.1...1.1.0 +.. _1.0.1: https://github.com/sprockets/sprockets.mixins.metrics/compare/1.0.0...1.0.1 .. _1.0.0: https://github.com/sprockets/sprockets.mixins.metrics/compare/0.9.0...1.0.0 .. _0.9.0: https://github.com/sprockets/sprockets.mixins.metrics/compare/0.0.0...0.9.0 diff --git a/sprockets/mixins/metrics/__init__.py b/sprockets/mixins/metrics/__init__.py index 41251fa..caaf9a5 100644 --- a/sprockets/mixins/metrics/__init__.py +++ b/sprockets/mixins/metrics/__init__.py @@ -8,6 +8,6 @@ except ImportError as error: def StatsdMixin(*args, **kwargs): raise error -version_info = (1, 0, 1) +version_info = (1, 1, 0) __version__ = '.'.join(str(v) for v in version_info) __all__ = ['__version__', 'version_info', 'InfluxDBMixin', 'StatsdMixin'] diff --git a/sprockets/mixins/metrics/influxdb.py b/sprockets/mixins/metrics/influxdb.py index 24c054e..b8f57a2 100644 --- a/sprockets/mixins/metrics/influxdb.py +++ b/sprockets/mixins/metrics/influxdb.py @@ -26,9 +26,6 @@ class InfluxDBConnection(object): """ - MAX_BUFFER_TIME = 5 - MAX_BUFFER_LENGTH = 100 - def __init__(self, write_url, database, io_loop=None, max_buffer_time=5, max_buffer_length=100): self.io_loop = ioloop.IOLoop.instance() if io_loop is None else io_loop