Class: StackTrace::Span
- Inherits:
-
Object
- Object
- StackTrace::Span
- Defined in:
- lib/stack_trace/span.rb
Instance Attribute Summary collapse
-
#exception ⇒ Object
writeonly
Sets the attribute exception.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(span) ⇒ Object
- #as_json ⇒ Object
- #close(trace_point) ⇒ Object
-
#initialize(receiver, method_name, args, parent) ⇒ Span
constructor
A new instance of Span.
Constructor Details
#initialize(receiver, method_name, args, parent) ⇒ Span
Returns a new instance of Span.
32 33 34 35 36 37 38 39 |
# File 'lib/stack_trace/span.rb', line 32 def initialize(receiver, method_name, args, parent) self.receiver = receiver self.method_name = method_name self.args = args self.parent = parent self.started_at = Time.now.to_f self.spans = [] end |
Instance Attribute Details
#exception=(value) ⇒ Object
Sets the attribute exception
30 31 32 |
# File 'lib/stack_trace/span.rb', line 30 def exception=(value) @exception = value end |
Class Method Details
.start_from(trace_point, parent) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/stack_trace/span.rb', line 6 def start_from(trace_point, parent) new( receiver(trace_point), trace_point.method_id, extract_arguments(trace_point), parent ) end |
Instance Method Details
#<<(span) ⇒ Object
41 42 43 |
# File 'lib/stack_trace/span.rb', line 41 def <<(span) (spans << span) && span end |
#as_json ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/stack_trace/span.rb', line 51 def as_json { receiver: receiver, method_name: method_name, arguments: args, value: value, exception: exception_as_json, time: time, spans: spans.map(&:as_json) } end |
#close(trace_point) ⇒ Object
45 46 47 48 49 |
# File 'lib/stack_trace/span.rb', line 45 def close(trace_point) self.value = trace_point.return_value.inspect self.finished_at = Time.now.to_f parent end |