MerlinDMC / fluent-plugin-input-gelf

A GELF input for Fluentd
MIT License
8 stars 15 forks source link

time handling concerns and casting bug #12

Open chris-u opened 4 years ago

chris-u commented 4 years ago

The fluent receiver should have the ability to decide if it should trust or not trust the timestamps provided by the client. Fluent uses "time" for lots of housekeeping chores and if a client provides a record with a timestamp far in the past or the future the data may end up in a location that isn't monitored.

The time data structure in fluent is not actually a float; it is a time_t second and an nsec, both integers. A client provided float timestamp must be truncated to a single INT or converted into two INTs; fluent yelps if you pass it a float

chris-u commented 4 years ago

Also I believe there is a logic bug in the unit test around time handling;

specifically the test checks to see if the timestamp as a float is the same as the provided timestamp assert_equal tests[i][:timestamp].to_f, emits[i][1] unless tests[i][:timestamp].nil?

but in the code that's being tested states: time = record.delete('timestamp').to_f if record.key?('timestamp')

so "timestamp" is always getting deleted, so the test always hits the unless case