Class: LogStash::PipelineReporter::Snapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/pipeline_reporter.rb

Overview

This is an immutable copy of the pipeline state, It is a proxy to a hash to allow us to add methods dynamically to the hash

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Snapshot

Returns a new instance of Snapshot.



10
11
12
# File 'lib/logstash/pipeline_reporter.rb', line 10

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth) ⇒ Object



27
28
29
# File 'lib/logstash/pipeline_reporter.rb', line 27

def method_missing(meth)
  @data[meth]
end

Instance Method Details

#format_threads_by_pluginObject



31
32
33
34
35
36
37
38
39
# File 'lib/logstash/pipeline_reporter.rb', line 31

def format_threads_by_plugin
  stalled_plugins = {}
  stalling_threads_info.each do |thr|
    key = (thr.delete("plugin") || "other")
    stalled_plugins[key] ||= []
    stalled_plugins[key] << thr
  end
  stalled_plugins
end

#to_hashObject



14
15
16
# File 'lib/logstash/pipeline_reporter.rb', line 14

def to_hash
  @data
end

#to_simple_hashObject



18
19
20
# File 'lib/logstash/pipeline_reporter.rb', line 18

def to_simple_hash
  {"inflight_count" => inflight_count, "stalling_thread_info" => format_threads_by_plugin}
end

#to_strObject Also known as: to_s



22
23
24
# File 'lib/logstash/pipeline_reporter.rb', line 22

def to_str
  to_simple_hash.to_s
end