lib/fluent/plugin/out_tdlog.rb in fluent-plugin-td-0.10.21 vs lib/fluent/plugin/out_tdlog.rb in fluent-plugin-td-0.10.22

- old
+ new

@@ -1,6 +1,7 @@ require 'td-client' +require 'fluent/plugin/td_plugin_version' module Fluent class TreasureDataLogOutput < BufferedOutput Plugin.register_output('tdlog', self) @@ -91,10 +92,11 @@ @record_size_limit = 32 * 1024 * 1024 # TODO @table_list = {} @auto_create_table = true @use_ssl = true @empty_gz_data = TreasureData::API.create_empty_gz_data + @user_agent = "fluent-plugin-td: #{TreasureDataPlugin::VERSION}".freeze end def configure(conf) super @@ -160,14 +162,17 @@ scr.configure(e) @anonymizes[key] = scr } - @anonymizes = nil if @anonymizes.empty? + if @anonymizes.empty? + @anonymizes = nil + else + log.warn "<anonymize> feature is deprecated and will be removed. Use fluent-plugin-anonymizer instead." + end @http_proxy = conf['http_proxy'] - @user_agent = "fluent-plugin-td: 0.10.21" # TODO: automatic increment version end def start super @@ -216,10 +221,11 @@ end } end record['time'] = time + record.delete(:time) if record.has_key?(:time) if record.size > @key_num_limit raise "Too many number of keys (#{record.size} keys)" # TODO include summary of the record end rescue => e @@ -295,11 +301,11 @@ io.pos = 0 retry end rescue => e elapsed = Time.now - start - ne = RuntimeError.new("Failed to upload to Treasure Data '#{database}.#{table}' table: #{$!} (#{size} bytes; #{elapsed} seconds)") + ne = RuntimeError.new("Failed to upload to Treasure Data '#{database}.#{table}' table: #{e.inspect} (#{size} bytes; #{elapsed} seconds)") ne.set_backtrace(e.backtrace) raise ne end end @@ -312,10 +318,10 @@ @client.import(database, table, "msgpack.gz", io, io.size) @table_list[key] = true rescue TreasureData::NotFoundError raise "Table #{key.inspect} does not exist on Treasure Data. Use 'td table:create #{database} #{table}' to create it." rescue => e - log.warn "failed to check existence of '#{database}.#{table}' table on Treasure Data", :error => e.to_s + log.warn "failed to check existence of '#{database}.#{table}' table on Treasure Data", :error => e.inspect log.debug_backtrace e.backtrace end end end