168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/fluent/plugin/out_kafka2.rb', line 168
def configure(conf)
super
if @brokers.size > 0
@seed_brokers = @brokers
log.info "brokers has been set: #{@seed_brokers}"
else
raise Fluent::ConfigError, 'No brokers specified. Need one broker at least.'
end
formatter_conf = conf.elements('format').first
unless formatter_conf
raise Fluent::ConfigError, "<format> section is required."
end
unless formatter_conf["@type"]
raise Fluent::ConfigError, "format/@type is required."
end
@formatter_proc = setup_formatter(formatter_conf)
if @default_topic.nil?
if @use_default_for_unknown_topic
raise Fluent::ConfigError, "default_topic must be set when use_default_for_unknown_topic is true"
end
if @chunk_keys.include?('topic') && !@chunk_key_tag
log.warn "Use 'topic' field of event record for topic but no fallback. Recommend to set default_topic or set 'tag' in buffer chunk keys like <buffer topic,tag>"
end
else
if @chunk_key_tag
log.warn "default_topic is set. Fluentd's event tag is not used for topic"
end
end
@producer_opts = {max_retries: @max_send_retries, required_acks: @required_acks, idempotent: @idempotent}
@producer_opts[:ack_timeout] = @ack_timeout if @ack_timeout
@producer_opts[:compression_codec] = @compression_codec.to_sym if @compression_codec
if @active_support_notification_regex
require 'active_support/notifications'
require 'active_support/core_ext/hash/keys'
ActiveSupport::Notifications.subscribe(Regexp.new(@active_support_notification_regex)) do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
message = event.payload.respond_to?(:stringify_keys) ? event.payload.stringify_keys : event.payload
@router.emit("fluent_kafka_stats.#{event.name}", Time.now.to_i, message)
end
end
@topic_key_sym = @topic_key.to_sym
@headers_from_record_accessors = {}
@headers_from_record.each do |key, value|
@headers_from_record_accessors[key] = record_accessor_create(value)
end
@exclude_field_accessors = @exclude_fields.map do |field|
record_accessor_create(field)
end
@record_field_accessor = nil
@record_field_accessor = record_accessor_create(@record_key) unless @record_key.nil?
end
|