logstash-plugins / logstash-input-gelf

Apache License 2.0
20 stars 39 forks source link

proper timestamp coercion to preserve microsecond precision #35

Closed colinsurprenant closed 8 years ago

colinsurprenant commented 8 years ago

this refactors, extends and replaces #32 this will fix elastic/logstash#4565

colinsurprenant commented 8 years ago

@rikwasmus, @alex88, @guyboertje comments/reviews ?

rikwasmus commented 8 years ago

Thank you for your rewrite, I do agree that the logic deserves its own testable function.

However, 2 issues:

And thank you both for your attention & help :)

colinsurprenant commented 8 years ago

@rikwasmus

Could you alter your tests to feed it BigDecimals instead of floats?

errr :stuck_out_tongue: thanks for respectfully reminding me to add the single test case this was all about in the first place! :laughing:

As you suggested and also @alex88 in the code comments, I optimized the coercion for the BigDecimal case and the rest. My original one-liner was an all-size-fits-all implementation but even if I think the performance impact is really minimal here, the code intent is a lot more clear now and, well, there is less casting and useless object creation done. :heavy_check_mark:

Let me know what you think.

rikwasmus commented 8 years ago

It looks awesome :smile: Except for a rogue timetstamp in the description of the JSON test (thanks for adding that as well) it gets my vote for shipping ;).

colinsurprenant commented 8 years ago

sweet djeezus, I keep on doing that typo :P ... elastic/logstash#4816

guyboertje commented 8 years ago

LGTM (I might have used build_event instead of new_event, because it does more than create a new event - but I not going to stand on ceremony)

colinsurprenant commented 8 years ago

Perfect! will merge and publish. Thanks all! :shipit:

colinsurprenant commented 8 years ago

Have a build error that will be fixed by elastic/logstash#4827 - want to merge that first then we will publish after, hopefully today.

colinsurprenant commented 8 years ago

elastic/logstash#4827 is merged but discovered another problem with BigDecimal handling. Fix awaiting reviews for merge in elastic/logstash#4838

colinsurprenant commented 8 years ago

published version 2.0.3