Class: Codebeacon::Tracer::ThreadLocalCallTreeManager
- Inherits:
-
Object
- Object
- Codebeacon::Tracer::ThreadLocalCallTreeManager
- Defined in:
- lib/codebeacon/tracer/src/models/thread_local_call_tree_manager.rb
Instance Attribute Summary collapse
-
#trace_id ⇒ Object
readonly
Returns the value of attribute trace_id.
-
#trees ⇒ Object
readonly
Returns the value of attribute trees.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #current ⇒ Object
-
#initialize(trace_id) ⇒ ThreadLocalCallTreeManager
constructor
A new instance of ThreadLocalCallTreeManager.
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_id ⇒ Object (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 |
#trees ⇒ Object (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
#cleanup ⇒ Object
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 |
#current ⇒ Object
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 |