mirror of
https://github.com/sprockets/sprockets.mixins.metrics.git
synced 2024-11-21 19:28:34 +00:00
Fix python 2.6 support issue for packaging
This commit is contained in:
parent
79781e1b1e
commit
a27f2976da
3 changed files with 18 additions and 6 deletions
|
@ -3,6 +3,10 @@
|
|||
Release History
|
||||
===============
|
||||
|
||||
`1.1.1`_ (9-Mar-2016)
|
||||
---------------------
|
||||
- Fix packaging woes part deux.
|
||||
|
||||
`1.1.0`_ (9-Mar-2016)
|
||||
---------------------
|
||||
- Update InfluxDB mixin to buffer measurements across requests based on a max time and/or length.
|
||||
|
@ -24,7 +28,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.1.0...master
|
||||
.. _Next Release: https://github.com/sprockets/sprockets.mixins.metrics/compare/1.1.1...master
|
||||
.. _1.1.1: https://github.com/sprockets/sprockets.mixins.metrics/compare/1.1.0...1.1.1
|
||||
.. _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
|
||||
|
|
|
@ -8,6 +8,6 @@ except ImportError as error:
|
|||
def StatsdMixin(*args, **kwargs):
|
||||
raise error
|
||||
|
||||
version_info = (1, 1, 0)
|
||||
version_info = (1, 1, 1)
|
||||
__version__ = '.'.join(str(v) for v in version_info)
|
||||
__all__ = ['__version__', 'version_info', 'InfluxDBMixin', 'StatsdMixin']
|
||||
|
|
|
@ -26,13 +26,20 @@ 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):
|
||||
max_buffer_time=None, max_buffer_length=None):
|
||||
self.io_loop = ioloop.IOLoop.instance() if io_loop is None else io_loop
|
||||
self.client = httpclient.AsyncHTTPClient()
|
||||
self.write_url = '{}?db={}'.format(write_url, database)
|
||||
|
||||
self._buffer = []
|
||||
if max_buffer_time is None:
|
||||
max_buffer_time = self.MAX_BUFFER_TIME
|
||||
if max_buffer_length is None:
|
||||
max_buffer_length = self.MAX_BUFFER_LENGTH
|
||||
self._max_buffer_time = float(max_buffer_time)
|
||||
self._max_buffer_length = int(max_buffer_length)
|
||||
self._last_write = self.io_loop.time()
|
||||
|
@ -96,10 +103,10 @@ class InfluxDBMixin(object):
|
|||
if self.SETTINGS_KEY in self.settings:
|
||||
settings = self.settings[self.SETTINGS_KEY]
|
||||
if 'db_connection' not in settings:
|
||||
keys = ('max_buffer_time', 'max_buffer_length')
|
||||
kwargs = {k: settings[k] for k in keys if k in settings}
|
||||
settings['db_connection'] = InfluxDBConnection(
|
||||
settings['write_url'], settings['database'], **kwargs)
|
||||
settings['write_url'], settings['database'],
|
||||
max_buffer_time=settings.get('max_buffer_time'),
|
||||
max_buffer_length=settings.get('max_buffer_length'))
|
||||
|
||||
self.__metrics = []
|
||||
self.__tags = {
|
||||
|
|
Loading…
Reference in a new issue