Move to millisecond precision

This commit is contained in:
Gavin M. Roy 2016-09-14 01:27:55 -04:00
parent f4245531b7
commit 98781c101d
3 changed files with 15 additions and 8 deletions

View file

@ -3,6 +3,10 @@
Release History
===============
`1.0.6`_ (14 Sep 2016)
----------------------
- Move to millisecond precision
`1.0.5`_ (14 Sep 2016)
----------------------
- Remove ``content_type`` tag
@ -34,10 +38,11 @@ Release History
----------------------
- Initial release
.. _1.0.6: https://github.com/sprockets/sprockets-influxdb/compare/1.0.5...1.0.6
.. _1.0.5: https://github.com/sprockets/sprockets-influxdb/compare/1.0.4...1.0.5
.. _1.0.4: https://github.com/sprockets/sprockets-influxdb/compare/1.0.3...1.0.4
.. _1.0.3: https://github.com/sprockets/sprockets-influxdb/compare/1.0.2...1.0.3
.. _1.0.2: https://github.com/sprockets/sprockets-influxdb/compare/1.0.1...1.0.2
.. _1.0.1: https://github.com/sprockets/sprockets-influxdb/compare/1.0.0...1.0.1
.. _1.0.0: https://github.com/sprockets/sprockets-influxdb/compare/0.0.0...1.0.0
.. _Next Release: https://github.com/sprockets/sprockets-influxdb/compare/1.0.5...master
.. _Next Release: https://github.com/sprockets/sprockets-influxdb/compare/1.0.6...master

View file

@ -17,7 +17,7 @@ except ImportError: # pragma: no cover
logging.critical('Could not import Tornado')
concurrent, httpclient, ioloop = None, None, None
version_info = (1, 0, 5)
version_info = (1, 0, 6)
__version__ = '.'.join(str(v) for v in version_info)
__all__ = ['__version__', 'version_info', 'add_measurement', 'flush',
'install', 'shutdown', 'Measurement']
@ -89,6 +89,8 @@ class InfluxDBMixin(object):
self.influxdb.set_field('correlation_id', self.correlation_id)
self.influxdb.set_field('duration', self.request.request_time())
self.influxdb.set_tag('status_code', self._status_code)
self.influxdb.set_tag('remote_ip', self.request.remote_ip)
self.influxdb.set_tag('remote_ip', self.request.remote_ip)
add_measurement(self.influxdb)
@ -498,7 +500,7 @@ def _write_measurements():
# Submit a batch for each database
for database in _measurements:
url = '{}?db={}&precision=seconds'.format(_base_url, database)
url = '{}?db={}&precision=ms'.format(_base_url, database)
# Get the measurements to submit
measurements = _measurements[database][:_max_batch_size]
@ -575,7 +577,7 @@ class Measurement(object):
','.join(['{}={}'.format(self._escape(k), self._escape(v))
for k, v in self.tags.items()]),
self._marshall_fields(),
int(time.time()))
int(time.time() * 1000))
def set_field(self, name, value):
"""Set the value of a field in the measurement.

View file

@ -31,8 +31,8 @@ class MeasurementTestCase(base.AsyncServerTestCase):
self.assertGreater(float(measurement.fields['duration']), 0.001)
self.assertLess(float(measurement.fields['duration']), 0.1)
self.assertGreaterEqual(measurement.timestamp, int(start_time))
self.assertLessEqual(measurement.timestamp, time.time())
self.assertGreaterEqual(measurement.timestamp/1000, int(start_time))
self.assertLessEqual(measurement.timestamp/1000, time.time())
def test_measurement_with_named_endpoint(self):
start_time = time.time()
@ -55,8 +55,8 @@ class MeasurementTestCase(base.AsyncServerTestCase):
self.assertGreater(float(measurement.fields['duration']), 0.001)
self.assertLess(float(measurement.fields['duration']), 0.1)
self.assertGreaterEqual(measurement.timestamp, int(start_time))
self.assertLessEqual(measurement.timestamp, time.time())
self.assertGreaterEqual(measurement.timestamp/1000, int(start_time))
self.assertLessEqual(measurement.timestamp/1000, time.time())
def test_measurement_with_param_endpoint(self):
result = self.fetch('/param/100')