Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions fluent/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def __init__(
buffer_overflow_handler=None,
nanosecond_precision=False,
msgpack_kwargs=None,
*,
forward_packet_error=True,
**kwargs,
):
"""
Expand All @@ -65,6 +67,7 @@ def __init__(
self.verbose = verbose
self.buffer_overflow_handler = buffer_overflow_handler
self.nanosecond_precision = nanosecond_precision
self.forward_packet_error = forward_packet_error
self.msgpack_kwargs = {} if msgpack_kwargs is None else msgpack_kwargs

self.socket = None
Expand All @@ -81,11 +84,11 @@ def emit(self, label, data):
return self.emit_with_time(label, cur_time, data)

def emit_with_time(self, label, timestamp, data):
if self.nanosecond_precision and isinstance(timestamp, float):
timestamp = EventTime(timestamp)
try:
bytes_ = self._make_packet(label, timestamp, data)
except Exception as e:
if not self.forward_packet_error:
raise
self.last_error = e
bytes_ = self._make_packet(
label,
Expand Down Expand Up @@ -129,6 +132,8 @@ def _make_packet(self, label, timestamp, data):
tag = ".".join((self.tag, label)) if self.tag else label
else:
tag = self.tag
if self.nanosecond_precision and isinstance(timestamp, float):
timestamp = EventTime(timestamp)
packet = (tag, timestamp, data)
if self.verbose:
print(packet)
Expand Down