Skip to content

Commit

Permalink
Merge 809fbb9 into 0aad65b
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceaulinic committed Aug 28, 2018
2 parents 0aad65b + 809fbb9 commit c2c2f59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/publisher/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,20 @@ You can specify a separate serialize per publisher, e.g.:
serializer: json
- cli:
serializer: pprint
.. _publisher-opts-strip-message-details:

``strip_message_details``: ``False``
------------------------------------

.. versionadded:: 0.7.0

Strip the ``message_details`` key before publishing the object.

Configuration example:

.. code-block:: yaml
publisher:
- kafka:
strip_message_details: true
4 changes: 4 additions & 0 deletions napalm_logs/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(self,
if not disable_security:
self.__safe = nacl.secret.SecretBox(private_key)
self.__signing_key = signing_key
self._strip_message_details = publisher_opts.pop('strip_message_details', False)
self._setup_transport()

def _exit_gracefully(self, signum, _):
Expand Down Expand Up @@ -166,6 +167,9 @@ def start(self):
log.error(error, exc_info=True)
raise NapalmLogsExit(error)
obj = umsgpack.unpackb(bin_obj)
if self._strip_message_details:
obj.pop('message_details', None)
bin_obj = self.serializer_fun(obj)
napalm_logs_publisher_received_messages.labels(
publisher_type=self._transport_type,
address=self.address,
Expand Down

0 comments on commit c2c2f59

Please sign in to comment.