diff --git a/lib/rackstash.rb b/lib/rackstash.rb index b0bdb44..051ed06 100644 --- a/lib/rackstash.rb +++ b/lib/rackstash.rb @@ -66,7 +66,7 @@ module Rackstash EMPTY_SET = Set.new.freeze # How many decimal places to render on ISO 8601 timestamps - ISO8601_PRECISION = 3 + ISO8601_PRECISION = 6 FIELD_MESSAGE = 'message'.freeze FIELD_TAGS = 'tags'.freeze diff --git a/spec/rackstash/buffer_spec.rb b/spec/rackstash/buffer_spec.rb index d00d366..3d0709d 100644 --- a/spec/rackstash/buffer_spec.rb +++ b/spec/rackstash/buffer_spec.rb @@ -33,7 +33,7 @@ describe Rackstash::Buffer do msg = double(message: 'Hello World', time: time) buffer.add_message msg - expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000Z' + expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000000Z' end context 'when buffering?' do @@ -111,12 +111,12 @@ describe Rackstash::Buffer do it 'resets the timestamp' do buffer.timestamp(Time.parse('2016-10-17 15:37:00 +02:00')) - expect(buffer.timestamp).to eql '2016-10-17T13:37:00.000Z' + expect(buffer.timestamp).to eql '2016-10-17T13:37:00.000000Z' buffer.clear expect(Time).to receive(:now).and_call_original - expect(buffer.timestamp).not_to eql '2016-10-17T13:37:00.000Z' + expect(buffer.timestamp).not_to eql '2016-10-17T13:37:00.000000Z' end end @@ -306,16 +306,16 @@ describe Rackstash::Buffer do expect(Time).to receive(:now).once.and_return(now) expect(now).to receive(:getutc).once.and_return(now.getutc) - expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000Z' - expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000Z' + expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000000Z' + expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000000Z' end it 'initializes @timestamp with the passed time' do now = Time.parse('2016-10-17 13:37:00 +03:00') expect(Time).not_to receive(:now) - expect(buffer.timestamp(now)).to eql '2016-10-17T10:37:00.000Z' - expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000Z' + expect(buffer.timestamp(now)).to eql '2016-10-17T10:37:00.000000Z' + expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000000Z' end it 'does not overwrites an already set timestamp' do @@ -323,13 +323,13 @@ describe Rackstash::Buffer do second = Time.parse('2016-10-17 20:20:20 +03:00') buffer.timestamp(first) - expect(buffer.timestamp).to eql '2016-10-17T07:10:10.000Z' + expect(buffer.timestamp).to eql '2016-10-17T07:10:10.000000Z' buffer.timestamp - expect(buffer.timestamp).to eql '2016-10-17T07:10:10.000Z' + expect(buffer.timestamp).to eql '2016-10-17T07:10:10.000000Z' buffer.timestamp(second) - expect(buffer.timestamp).to eql '2016-10-17T07:10:10.000Z' + expect(buffer.timestamp).to eql '2016-10-17T07:10:10.000000Z' end end end diff --git a/spec/rackstash/fields/abstract_collection_spec.rb b/spec/rackstash/fields/abstract_collection_spec.rb index 7a8f017..843c5cd 100644 --- a/spec/rackstash/fields/abstract_collection_spec.rb +++ b/spec/rackstash/fields/abstract_collection_spec.rb @@ -356,7 +356,7 @@ describe Rackstash::Fields::AbstractCollection do it 'formats Time as an ISO 8601 UTC timestamp' do time = Time.parse('2016-10-17 16:37:42 +03:00') - expect(normalize(time)).to eql '2016-10-17T13:37:42.000Z' + expect(normalize(time)).to eql '2016-10-17T13:37:42.000000Z' expect(normalize(time).encoding).to eql Encoding::UTF_8 expect(normalize(time)).to be_frozen end @@ -364,7 +364,7 @@ describe Rackstash::Fields::AbstractCollection do it 'formats DateTime as an ISO 8601 UTC timestamp' do datetime = DateTime.parse('2016-10-17 15:37:42 CEST') # UTC +02:00 - expect(normalize(datetime)).to eql '2016-10-17T13:37:42.000Z' + expect(normalize(datetime)).to eql '2016-10-17T13:37:42.000000Z' expect(normalize(datetime).encoding).to eql Encoding::UTF_8 expect(normalize(datetime)).to be_frozen end