Skip to content

Commit

Permalink
Use timestamp with subsecond precision
Browse files Browse the repository at this point in the history
Previously the timestamp did have a a precision of one second. The fraction got lost.
The timestamp is a double now and contains the fractions of a second.

Fixes fluent#12

Signed-off-by: Edwin Engelen <edwin@engelen.name>
  • Loading branch information
EdwinEngelen committed Mar 24, 2020
1 parent d0e932a commit 4d19ccb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/NLog.Targets.Fluentd/Fluentd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ internal class FluentdEmitter

public void Emit(DateTime timestamp, string tag, IDictionary<string, object> data)
{
long unixTimestamp = timestamp.ToUniversalTime().Subtract(unixEpoch).Ticks / 10000000;
double floatTimestamp = (double)timestamp.ToUniversalTime().Subtract(unixEpoch).Ticks / (10 * 1000 * 1000);
this.packer.PackArrayHeader(3);
this.packer.PackString(tag, Encoding.UTF8);
this.packer.Pack((ulong)unixTimestamp);
this.packer.Pack(floatTimestamp);
this.packer.Pack(data, serializationContext);
this.destination.Flush(); // Change to packer.Flush() when packer is upgraded
}
Expand Down

0 comments on commit 4d19ccb

Please sign in to comment.