Logback provides log event timestamp with millisecond precision. In order to preserve the message order as in other Logback outputs (such as CONSOLE or FILE), Loki4j used nanoCounter to emulate this order for Loki (otherwise events with the same millisecond are randomly mixed). nanoCounter was implemented as AtomicInteger with the following update procedure:
nanoCounter.updateAndGet(i -> i < 999_999 ? i + 1 : 0);
So nanos was a simple global count of the event that is being reset each 1M events. This reset could cause 'out of order' for all subsequent events with the same millisecond.
In #87 nanoCounter was removed completely with nanos part of the timestamp. However, this is not a solution for a problem. nanoCounter needs to be re-implemented.
Logback provides log event timestamp with millisecond precision. In order to preserve the message order as in other Logback outputs (such as CONSOLE or FILE), Loki4j used
nanoCounter
to emulate this order for Loki (otherwise events with the same millisecond are randomly mixed).nanoCounter
was implemented asAtomicInteger
with the following update procedure:So
nanos
was a simple global count of the event that is being reset each 1M events. This reset could cause 'out of order' for all subsequent events with the same millisecond.