Class: LogStash::Inputs::Generator
- Inherits:
-
Threadable
- Object
- Threadable
- LogStash::Inputs::Generator
- Defined in:
- lib/logstash/inputs/generator.rb
Overview
Generate random log events.
The general intention of this is to test performance of plugins.
An event is generated first
Instance Method Summary collapse
- #register ⇒ Object
-
#run(queue) ⇒ Object
def register.
- #teardown ⇒ Object
Instance Method Details
#register ⇒ Object
50 51 52 53 |
# File 'lib/logstash/inputs/generator.rb', line 50 def register @host = Socket.gethostname @count = @count.first if @count.is_a?(Array) end |
#run(queue) ⇒ Object
def register
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/logstash/inputs/generator.rb', line 55 def run(queue) number = 0 if @message == "stdin" @logger.info("Generator plugin reading a line from stdin") @message = $stdin.readline @logger.debug("Generator line read complete", :message => @message) end @lines = [@message] if @lines.nil? while !finished? && (@count <= 0 || number < @count) @lines.each do |line| @codec.decode(line.clone) do |event| decorate(event) event["host"] = @host event["sequence"] = number queue << event end end number += 1 end # loop if @codec.respond_to?(:flush) @codec.flush do |event| decorate(event) event["host"] = @host queue << event end end end |
#teardown ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/logstash/inputs/generator.rb', line 87 def teardown @codec.flush do |event| decorate(event) event["host"] = @host queue << event end finished end |