Class: AWS::Flow::Core::AsyncBacktrace Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/flow/async_backtrace.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, backtrace) ⇒ AsyncBacktrace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AsyncBacktrace.



25
26
27
28
# File 'lib/aws/flow/async_backtrace.rb', line 25

def initialize(parent, backtrace)
  @backtrace = AsyncBacktrace.filter(backtrace)
  @parent = parent
end

Class Method Details

.caller(skip) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



108
109
110
111
112
113
# File 'lib/aws/flow/async_backtrace.rb', line 108

def caller(skip)
  random_var = Kernel.caller 0
  this_stuff =  1.upto(6).map { |x| Kernel.caller(x) }
  other_var = Kernel.caller skip
  Kernel.caller(@disable_filtering ? 0 : skip)
end

.create(parent, frames_to_skip) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
46
47
48
49
# File 'lib/aws/flow/async_backtrace.rb', line 43

def create(parent, frames_to_skip)

  unless @disable_async_backtrace
    b = AsyncBacktrace.caller(frames_to_skip)
    AsyncBacktrace.new(parent, b)
  end
end

.create_from_exception(parent, exception) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



52
53
54
55
56
# File 'lib/aws/flow/async_backtrace.rb', line 52

def create_from_exception(parent, exception)
  unless @disable_async_backtrace
    AsyncBacktrace.new(parent, exception.backtrace);
  end
end

.disableObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



98
99
100
# File 'lib/aws/flow/async_backtrace.rb', line 98

def disable
  @disable_async_backtrace = true
end

.disable_filteringObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



88
89
90
# File 'lib/aws/flow/async_backtrace.rb', line 88

def disable_filtering
  @disable_filtering = true
end

.enableObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



103
104
105
# File 'lib/aws/flow/async_backtrace.rb', line 103

def enable
  @disable_async_backtrace = false
end

.enable_filteringObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



93
94
95
# File 'lib/aws/flow/async_backtrace.rb', line 93

def enable_filtering
  @disable_filtering = false
end

.filter(backtrace) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO:

The correct implementation should not have framework frames before application frames as it is expected to call Kernel.caller with the correct number. In cases when this number is not correct, the frames are kept to not create confusion.

Removes all framework-related frames after application frames. Keep framework frames before application frames.



67
68
69
70
71
72
73
# File 'lib/aws/flow/async_backtrace.rb', line 67

def filter(backtrace)
  if @disable_filtering
    backtrace
  else
    do_filter(backtrace)
  end
end

.merge(*backtraces) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



76
77
78
79
80
81
82
83
84
85
# File 'lib/aws/flow/async_backtrace.rb', line 76

def merge(*backtraces)
  result = []
  backtraces.each do | b |
    if b
      result << "------ continuation ------" if result.size > 0
      result += b
    end
  end
  result
end

Instance Method Details

#backtraceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
36
37
# File 'lib/aws/flow/async_backtrace.rb', line 31

def backtrace
  if @parent
    AsyncBacktrace.merge(@backtrace, @parent.backtrace)
  else
    @backtrace
  end
end