Class: Fluent::LogDNAOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::LogDNAOutput
- Defined in:
- lib/fluent/plugin/out_logdna.rb
Constant Summary collapse
- MAX_RETRIES =
5
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Instance Method Details
#configure(conf) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fluent/plugin/out_logdna.rb', line 22 def configure(conf) super @host = conf["hostname"] # make these two variables globals timeout_unit_map = { s: 1.0, ms: 0.001 } timeout_regex = Regexp.new("^([0-9]+)\s*(#{timeout_unit_map.keys.join('|')})$") # this section goes into this part of the code num_component = 30.0 unit_component = "s" timeout_regex.match(@request_timeout) do |match| num_component = match[1].to_f unit_component = match[2] end @request_timeout = num_component * timeout_unit_map[unit_component.to_sym] end |
#format(tag, time, record) ⇒ Object
57 58 59 |
# File 'lib/fluent/plugin/out_logdna.rb', line 57 def format(tag, time, record) [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
52 53 54 55 |
# File 'lib/fluent/plugin/out_logdna.rb', line 52 def shutdown super @ingester.close if @ingester end |
#start ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/fluent/plugin/out_logdna.rb', line 42 def start super require "json" require "base64" require "http" HTTP. = { keep_alive_timeout: 60 } @ingester = HTTP.persistent @ingester_domain @requests = Queue.new end |
#write(chunk) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/fluent/plugin/out_logdna.rb', line 61 def write(chunk) body = chunk_to_body(chunk) response = send_request(body) raise "Encountered server error" if response.code >= 400 response.flush end |