Class: Callstacking::Rails::Spans

Inherits:
Object
  • Object
show all
Defined in:
lib/callstacking/rails/spans.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpans

Returns a new instance of Spans.



7
8
9
# File 'lib/callstacking/rails/spans.rb', line 7

def initialize
  reset
end

Instance Attribute Details

#call_entry_callbackObject

Returns the value of attribute call_entry_callback.



5
6
7
# File 'lib/callstacking/rails/spans.rb', line 5

def call_entry_callback
  @call_entry_callback
end

#call_return_callbackObject

Returns the value of attribute call_return_callback.



5
6
7
# File 'lib/callstacking/rails/spans.rb', line 5

def call_return_callback
  @call_return_callback
end

#nesting_levelObject

Returns the value of attribute nesting_level.



4
5
6
# File 'lib/callstacking/rails/spans.rb', line 4

def nesting_level
  @nesting_level
end

#order_numObject

Returns the value of attribute order_num.



4
5
6
# File 'lib/callstacking/rails/spans.rb', line 4

def order_num
  @order_num
end

#previous_entryObject

Returns the value of attribute previous_entry.



4
5
6
# File 'lib/callstacking/rails/spans.rb', line 4

def previous_entry
  @previous_entry
end

Instance Method Details

#call_entry(klass, method_name, arguments, path, line_no, method_source) ⇒ Object



21
22
23
24
25
# File 'lib/callstacking/rails/spans.rb', line 21

def call_entry(klass, method_name, arguments, path, line_no, method_source)
  @nesting_level+=1
  @previous_entry = previous_event(klass, method_name)
  @call_entry_callback.call(@nesting_level, increment_order_num, klass, method_name, arguments, path, line_no, method_source)
end

#call_return(klass, method_name, path, line_no, return_val, method_source) ⇒ Object



27
28
29
30
31
# File 'lib/callstacking/rails/spans.rb', line 27

def call_return(klass, method_name, path, line_no, return_val, method_source)
  @call_return_callback.call(coupled_callee(klass, method_name), @nesting_level,
                             increment_order_num, klass, method_name, path, line_no, return_val, method_source)
  @nesting_level-=1
end

#increment_nesting_levelObject



16
17
18
19
# File 'lib/callstacking/rails/spans.rb', line 16

def increment_nesting_level
  @nesting_level+=1
  @nesting_level
end

#increment_order_numObject



11
12
13
14
# File 'lib/callstacking/rails/spans.rb', line 11

def increment_order_num
  @order_num+=1
  @order_num
end

#on_call_entry(&block) ⇒ Object



33
34
35
# File 'lib/callstacking/rails/spans.rb', line 33

def on_call_entry(&block)
  @call_entry_callback = block
end

#on_call_return(&block) ⇒ Object



37
38
39
# File 'lib/callstacking/rails/spans.rb', line 37

def on_call_return(&block)
  @call_return_callback = block
end

#resetObject



41
42
43
44
45
# File 'lib/callstacking/rails/spans.rb', line 41

def reset
  @nesting_level = -1
  @order_num = -1
  @previous_entry = nil
end