python-logging-loki icon indicating copy to clipboard operation
python-logging-loki copied to clipboard

V1 timestamp

Open andresp opened this issue 4 years ago • 1 comments

Should the V1 emitter timestamp be retrieved from record.created, just like it used to be in V0?

This is how it was set for a V0 record and there seems to be no reason why this shouldn't also apply to V1. The divergence makes a migration more difficult due to the inconsistent handling.

Suggestion for change:

ts = rfc3339.format_microsecond(record.created)

Happy to submit a pull request with the change, if contributors and @GreyZmeem agree.

andresp avatar Jan 18 '21 22:01 andresp

I actually changed that line to:

ts = str(time.time_ns())

v1 expects nanoseconds and that is now a builtin function since Python 3.7

https://docs.python.org/3.7/library/time.html#time.time_ns

Lawouach avatar Feb 15 '22 20:02 Lawouach