Skip to content

Commit

Permalink
Logging and InfluxDB Updates
Browse files Browse the repository at this point in the history
- Dont add tag ENVIRONMENT tag, nor the correlation-id field
- Prep for release
  • Loading branch information
gmr committed Oct 14, 2016
1 parent 9b22c3c commit 9b58dc0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
15 changes: 11 additions & 4 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Release History
===============

`1.1.0`_ (12 Oct 2016)
----------------------
- Remove the service tag in InfluxDB
- Remove the correlation-id field value
- Collect all of the paged query results

`1.0.2`_ (26 Sep 2016)
----------------------
- Fix a mixin InfluxDB integration issue
Expand All @@ -18,7 +24,8 @@ Release History
`Next Release`_
---------------

.. _Next Release: https://github.com/sprockets/sprockets_dynamodb/compare/1.0.2...master
.. _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_dynamodb/compare/1.1.0...master
.. _1.1.0: https://github.com/sprockets/sprockets-dynamodb/compare/1.0.2...1.1.0
.. _1.0.2: https://github.com/sprockets/sprockets-dynamodb/compare/1.0.1...1.0.2
.. _1.0.1: https://github.com/sprockets/sprockets-dynamodb/compare/1.0.0...1.0.1
.. _1.0.0: https://github.com/sprockets/sprockets-dynamodb/compare/0.0.0...1.0.0
2 changes: 1 addition & 1 deletion sprockets_dynamodb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import logging

version_info = (1, 0, 2)
version_info = (1, 1, 0)
__version__ = '.'.join(str(v) for v in version_info)

logging.getLogger(__name__).addHandler(logging.NullHandler())
Expand Down
13 changes: 5 additions & 8 deletions sprockets_dynamodb/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def initialize(self):
self.application.dynamodb.set_instrumentation_callback(
self._record_dynamodb_execution)

@staticmethod
def _on_dynamodb_exception(error):
def _on_dynamodb_exception(self, error):
"""Dynamically handle DynamoDB exceptions, returning HTTP error
responses.
Expand All @@ -39,22 +38,20 @@ def _on_dynamodb_exception(error):
elif isinstance(error, (exceptions.ThroughputExceeded,
exceptions.ThrottlingException)):
raise web.HTTPError(429, reason='Too Many Requests')
if hasattr(self, 'logger'):
self.logger.error('DynamoDB Error: %s', error)
raise web.HTTPError(500, reason=str(error))

def _record_dynamodb_execution(self, measurements):
@staticmethod
def _record_dynamodb_execution(measurements):
for row in measurements:
measurement = influxdb.Measurement(INFLUXDB_DATABASE,
INFLUXDB_MEASUREMENT)
measurement.set_timestamp(row.timestamp)
measurement.set_tag('action', row.action)
measurement.set_tag('table', row.table)
measurement.set_tag('attempt', row.attempt)
for key in {'SERVICE', 'ENVIRONMENT'}:
if os.environ.get(key):
measurement.set_tag(key.lower(), os.environ[key])
if row.error:
measurement.set_tag('error', row.error)
if hasattr(self, 'correlation_id'):
measurement.set_field('correlation_id', self.correlation_id)
measurement.set_field('duration', row.duration)
influxdb.add_measurement(measurement)

0 comments on commit 9b58dc0

Please sign in to comment.