fluent / fluent-plugin-mongo

MongoDB input and output plugin for Fluentd
https://docs.fluentd.org/output/mongo
173 stars 61 forks source link

Ruby's Date objects are not stored properly #18

Closed saki7 closed 12 years ago

saki7 commented 12 years ago

When you pass Ruby's date related objects (such as Date, Time, DateTime) to Fluent::Logger#post, out_mongo stores it as a plain string in mongodb. I think it must be stored as an ISODate("...") format, like the way usual timestamps are stored.


My code: Fluent::Logger.post('mytag', {text: 'foo', created_at: DateTime.now})

Results in:

{
  "_id" : ObjectId("50b37f022ed6f3145700005d"),
  "text" : "foo",
  "created_at" : "2012-11-26T23:38:51+09:00",
  "time" : ISODate("2012-11-26T14:38:51Z")
}

Is this fluent-plugin-mongo's problem? Or is it to_msgpack related problem? I'm quite not sure, but it must be related with the serialization process.

repeatedly commented 12 years ago

This is not fluent-plugin-mongo and to_msgpack problem. Ruby's Yajl and JSON convert Time related object into String object. The cause is this conversion rule in fluent-logger-ruby.

repeatedly commented 12 years ago

I close this issue.

saki7 commented 12 years ago

I see. Thanks!