lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-1.3.4 vs lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-1.4.0
- old
+ new
@@ -3,10 +3,11 @@
require 'fluent/timezone'
require 'aws-sdk-s3'
require 'zlib'
require 'time'
require 'tempfile'
+require 'securerandom'
module Fluent::Plugin
class S3Output < Output
Fluent::Plugin.register_output('s3', self)
@@ -382,11 +383,11 @@
unique_hex.reverse! # unique_hex is like (time_sec, time_usec, rand) => reversing gives more randomness
unique_hex[0...@hex_random_length]
end
def uuid_random
- ::UUIDTools::UUID.random_create.to_s
+ SecureRandom.uuid
end
# This is stolen from Fluentd
def timekey_to_timeformat(timekey)
case timekey
@@ -439,20 +440,9 @@
raise Fluent::ConfigError, %!#{ph} placeholder in s3_object_key_format is removed!
end
}
if @s3_object_key_format.include?('%{uuid_flush}')
- # test uuidtools works or not
- begin
- require 'uuidtools'
- rescue LoadError
- raise Fluent::ConfigError, "uuidtools gem not found. Install uuidtools gem first"
- end
- begin
- uuid_random
- rescue => e
- raise Fluent::ConfigError, "Generating uuid doesn't work. Can't use %{uuid_flush} on this environment. #{e}"
- end
@uuid_flush_enabled = true
end
@s3_object_key_format.gsub('%{hostname}') { |expr|
log.warn "%{hostname} will be removed in the future. Use \"\#{Socket.gethostname}\" instead"