Class: Instana::Collector::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/instana/collectors/thread.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeThread

Returns a new instance of Thread.



6
7
8
9
10
# File 'lib/instana/collectors/thread.rb', line 6

def initialize
  @payload_key = :thread
  @last_report = {}
  @this_count = {}
end

Instance Attribute Details

#payload_keyObject

Returns the value of attribute payload_key.



4
5
6
# File 'lib/instana/collectors/thread.rb', line 4

def payload_key
  @payload_key
end

Instance Method Details

#collectObject

collect

To collect thread count



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/instana/collectors/thread.rb', line 17

def collect
  @this_count[:count] = ::Thread.list.count

  @this_count = ::Instana::Util.enforce_deltas(@this_count, @last_report)

  unless @this_count.empty?
    @last_report.merge!(@this_count)
    @this_count
  else
    nil
  end
rescue => e
  ::Instana.logger.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
  ::Instana.logger.debug e.backtrace.join("\r\n")
end