Class: Fluent::BaritoVMOutput

Inherits:
BufferedOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_barito_vm.rb

Constant Summary collapse

PLUGIN_NAME =
"barito_vm"

Instance Method Summary collapse

Instance Method Details

#format(tag, time, record) ⇒ Object

Overide from BufferedOutput



24
25
26
# File 'lib/fluent/plugin/out_barito_vm.rb', line 24

def format(tag, time, record)
  [tag, time, record].to_msgpack
end

#startObject

Overide from BufferedOutput



19
20
21
# File 'lib/fluent/plugin/out_barito_vm.rb', line 19

def start
  super
end

#write(chunk) ⇒ Object

Overide from BufferedOutput



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fluent/plugin/out_barito_vm.rb', line 29

def write(chunk)
  chunk.msgpack_each do |tag, time, record|
    transport = Fluent::Plugin::BaritoTransport.new(@produce_url, log)
    trail = Fluent::Plugin::ClientTrail.new(false)
    timber = Fluent::Plugin::TimberFactory::create_timber(tag, time, record, trail)

    if @application_secret.nil? or @application_secret.empty?
      next if @application_group_secret.nil? or @application_name.nil?
      header = {
        content_type: :json,
        'X-App-Group-Secret' => @application_group_secret,
        'X-App-Name' => @application_name
      }
    else
      header = {content_type: :json, 'X-App-Secret' => @application_secret}
    end
    transport.send(timber, header)
  end
end