Class: LogStash::Filters::Railsparallelrequest

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/filters/railsparallelrequest.rb

Constant Summary

Constants inherited from Base

Base::RESERVED

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#execute, #threadsafe?

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

#initialize(config = {}) ⇒ Railsparallelrequest

Returns a new instance of Railsparallelrequest.



17
18
19
20
21
22
23
24
# File 'lib/logstash/filters/railsparallelrequest.rb', line 17

def initialize(config = {})
  super
  @threadsafe = false
  @pending = Hash.new
  @last_event = nil
  @recently_error = nil
  @last_uuid = nil
end

Instance Method Details

#filter(event) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/logstash/filters/railsparallelrequest.rb', line 28

def filter(event)
  return unless filter?(event)
  return if event["tags"].include? self.class.config_name

  event["tags"] << self.class.config_name

  line = event["message"]

  if line =~ /^\[(.*?)\]/
    uuid = $1
    event["uuid"] = uuid
    if @recently_error
      if @last_uuid == uuid
        merge_events(@recently_error, event, uuid)
        event.cancel
        return
      else
        @recently_error.uncancel
        yield @recently_error
        @recently_error = nil
      end
    end

    @last_uuid = uuid
    if @pending[uuid]
      merge_events(@pending[uuid], event, uuid)
    else
      @pending[uuid] = event
    end
    @last_event = @pending[uuid]

    if line =~ /Error/
      event.overwrite(@pending[uuid].to_hash)
      @pending.delete uuid
      @recently_error = event
    elsif line =~ /Completed/
      event.overwrite(@pending[uuid])
      @pending.delete uuid
      return
    end
    event.cancel
  elsif @last_event
    @last_event.append(event)
    event.cancel
  end
end

#flushObject



75
76
77
78
79
# File 'lib/logstash/filters/railsparallelrequest.rb', line 75

def flush
  events = @pending.values.each { |event| event.uncancel }
  @pending.clear
  events
end

#registerObject



26
# File 'lib/logstash/filters/railsparallelrequest.rb', line 26

def register ;end