Class: Codebeacon::Tracer::ThreadLocalCallTreeManager

Inherits:
Object
  • Object
show all
Defined in:
lib/codebeacon/tracer/src/models/thread_local_call_tree_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trace_id) ⇒ ThreadLocalCallTreeManager

Returns a new instance of ThreadLocalCallTreeManager.



8
9
10
11
# File 'lib/codebeacon/tracer/src/models/thread_local_call_tree_manager.rb', line 8

def initialize(trace_id)
  @trees = []
  @trace_id = trace_id
end

Instance Attribute Details

#trace_idObject (readonly)

Returns the value of attribute trace_id.



6
7
8
# File 'lib/codebeacon/tracer/src/models/thread_local_call_tree_manager.rb', line 6

def trace_id
  @trace_id
end

#treesObject (readonly)

Returns the value of attribute trees.



6
7
8
# File 'lib/codebeacon/tracer/src/models/thread_local_call_tree_manager.rb', line 6

def trees
  @trees
end

Instance Method Details

#cleanupObject



22
23
24
25
26
27
28
# File 'lib/codebeacon/tracer/src/models/thread_local_call_tree_manager.rb', line 22

def cleanup()
  Thread.list.each do |thread|
    if thread[thread_key]
      thread[thread_key] = nil
    end
  end
end

#currentObject



13
14
15
16
17
18
19
20
# File 'lib/codebeacon/tracer/src/models/thread_local_call_tree_manager.rb', line 13

def current()
  Thread.current[thread_key] ||= begin
    CallTree.new(Thread.current).tap do |tree|
      Codebeacon::Tracer.logger.debug("Creating new call tree for thread: #{Thread.current} with trace_id: #{trace_id}")
      @trees << tree
    end
  end
end