Class: Fluent::HttpShadowOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::HttpShadowOutput
- Defined in:
- lib/fluent/plugin/out_http_shadow.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ HttpShadowOutput
constructor
A new instance of HttpShadowOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ HttpShadowOutput
5 6 7 8 9 10 |
# File 'lib/fluent/plugin/out_http_shadow.rb', line 5 def initialize super require 'erb' require 'typhoeus' require "addressable/uri" end |
Instance Method Details
#configure(conf) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/fluent/plugin/out_http_shadow.rb', line 26 def configure(conf) super if @host.nil? && @host_hash.nil? raise ConfigError, "out_http_shadow: required to @host or @host_hash." end end |
#format(tag, time, record) ⇒ Object
46 47 48 |
# File 'lib/fluent/plugin/out_http_shadow.rb', line 46 def format(tag, time, record) [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
42 43 44 |
# File 'lib/fluent/plugin/out_http_shadow.rb', line 42 def shutdown super end |
#start ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/fluent/plugin/out_http_shadow.rb', line 33 def start super @regexp = /\$\{([^}]+)\}/ @path_format = ERB.new(@path_format.gsub(@regexp, "<%=record['" + '\1' + "'] %>")) @headers = get_formatter(@header_hash) = get_formatter() end |
#write(chunk) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fluent/plugin/out_http_shadow.rb', line 50 def write(chunk) records = [] chunk.msgpack_each do |tag, time, record| records << record end sampling_size = (records.size * (@rate * 0.01)).to_i if @rate > 100 orig_records = records.dup loop do records.concat(orig_records) break if sampling_size < records.size end end send_request_parallel(records.first(sampling_size)) end |