Class: RorVsWild::Execution
- Inherits:
-
Object
- Object
- RorVsWild::Execution
- Defined in:
- lib/rorvswild/execution.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#error_context ⇒ Object
readonly
Returns the value of attribute error_context.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#section_stack ⇒ Object
readonly
Returns the value of attribute section_stack.
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
Instance Method Summary collapse
- #add_exception(exception) ⇒ Object
- #add_queue_time(queue_time_ms) ⇒ Object
- #add_section(section) ⇒ Object
- #as_json(options = nil) ⇒ Object
-
#initialize(name, parameters) ⇒ Execution
constructor
A new instance of Execution.
- #merge_error_context(hash) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(name, parameters) ⇒ Execution
Returns a new instance of Execution.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rorvswild/execution.rb', line 9 def initialize(name, parameters) @name = name @parameters = parameters @runtime = nil @error = nil @error_context = nil @started_at = RorVsWild.clock_milliseconds @gc_section = Section.start_gc_timing @environment = Host.to_h @section_stack = [] @sections = [] end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
7 8 9 |
# File 'lib/rorvswild/execution.rb', line 7 def error @error end |
#error_context ⇒ Object (readonly)
Returns the value of attribute error_context.
5 6 7 |
# File 'lib/rorvswild/execution.rb', line 5 def error_context @error_context end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/rorvswild/execution.rb', line 7 def name @name end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
5 6 7 |
# File 'lib/rorvswild/execution.rb', line 5 def parameters @parameters end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
5 6 7 |
# File 'lib/rorvswild/execution.rb', line 5 def runtime @runtime end |
#section_stack ⇒ Object (readonly)
Returns the value of attribute section_stack.
5 6 7 |
# File 'lib/rorvswild/execution.rb', line 5 def section_stack @section_stack end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
5 6 7 |
# File 'lib/rorvswild/execution.rb', line 5 def sections @sections end |
Instance Method Details
#add_exception(exception) ⇒ Object
59 60 61 |
# File 'lib/rorvswild/execution.rb', line 59 def add_exception(exception) @error = Error.new(exception) if !RorVsWild.agent.ignored_exception?(exception) && !@error end |
#add_queue_time(queue_time_ms) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rorvswild/execution.rb', line 31 def add_queue_time(queue_time_ms) return unless queue_time_ms @started_at -= queue_time_ms section = Section.new section.total_ms = queue_time_ms section.gc_time_ms = 0 section.file = "queue" section.line = 0 section.kind = "queue" add_section(section) end |
#add_section(section) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rorvswild/execution.rb', line 23 def add_section(section) if sibling = @sections.find { |s| s.sibling?(section) } sibling.merge(section) else @sections << section end end |
#as_json(options = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/rorvswild/execution.rb', line 49 def as_json( = nil) { name: name, runtime: @runtime, error: @error && @error.as_json(), sections: @sections.map(&:as_json), environment: Host.to_h, } end |
#merge_error_context(hash) ⇒ Object
63 64 65 |
# File 'lib/rorvswild/execution.rb', line 63 def merge_error_context(hash) @error_context = @error_context ? @error_context.merge(hash) : hash end |
#stop ⇒ Object
43 44 45 46 47 |
# File 'lib/rorvswild/execution.rb', line 43 def stop Section.stop_gc_timing(@gc_section) @sections << @gc_section if @gc_section.calls > 0 && @gc_section.total_ms > 0 @runtime = RorVsWild.clock_milliseconds - @started_at end |