lib/fluent/plugin/out_tdlog.rb in fluent-plugin-td-0.10.24 vs lib/fluent/plugin/out_tdlog.rb in fluent-plugin-td-0.10.25

- old
+ new

@@ -214,10 +214,12 @@ end begin record.to_msgpack(out) rescue RangeError + # In msgpack v0.5, 'out' becomes String, not Buffer. This is not a problem because Buffer has a compatibility with String + out = out.to_s[0, off] TreasureData::API.normalized_msgpack(record, out) end noff = out.size sz = noff - off @@ -243,11 +245,11 @@ def write(chunk) unique_id = chunk.unique_id database, table = chunk.key.split('.', 2) FileUtils.mkdir_p(@tmpdir) unless @tmpdir.nil? - f = Tempfile.new("tdlog-", @tmpdir) + f = Tempfile.new("tdlog-#{chunk.key}-", @tmpdir) w = Zlib::GzipWriter.new(f) chunk.write_to(w) w.finish w = nil @@ -256,10 +258,10 @@ f.pos = 0 upload(database, table, f, size, unique_id) ensure w.close if w - f.close if f + f.close(true) if f end def upload(database, table, io, size, unique_id) unique_str = unique_id.unpack('C*').map { |x| "%02x" % x }.join log.trace { "uploading logs to Treasure Data database=#{database} table=#{table} (#{size}bytes)" }