Skip to content

Commit 4d19ccb

Browse files
committed
Use timestamp with subsecond precision
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 #12 Signed-off-by: Edwin Engelen <[email protected]>
1 parent d0e932a commit 4d19ccb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/NLog.Targets.Fluentd/Fluentd.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ internal class FluentdEmitter
161161

162162
public void Emit(DateTime timestamp, string tag, IDictionary<string, object> data)
163163
{
164-
long unixTimestamp = timestamp.ToUniversalTime().Subtract(unixEpoch).Ticks / 10000000;
164+
double floatTimestamp = (double)timestamp.ToUniversalTime().Subtract(unixEpoch).Ticks / (10 * 1000 * 1000);
165165
this.packer.PackArrayHeader(3);
166166
this.packer.PackString(tag, Encoding.UTF8);
167-
this.packer.Pack((ulong)unixTimestamp);
167+
this.packer.Pack(floatTimestamp);
168168
this.packer.Pack(data, serializationContext);
169169
this.destination.Flush(); // Change to packer.Flush() when packer is upgraded
170170
}

0 commit comments

Comments
 (0)