Class: Regent::Span
- Inherits:
-
Object
- Object
- Regent::Span
- Includes:
- Concerns::Durationable, Concerns::Identifiable
- Defined in:
- lib/regent/span.rb
Defined Under Namespace
Modules: Type
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#completed? ⇒ Boolean
Whether the span is completed.
-
#initialize(type:, arguments:, logger: Logger.new) ⇒ Span
constructor
A new instance of Span.
-
#replay ⇒ String
The output of the span.
-
#run ⇒ String
The output of the span.
-
#running? ⇒ Boolean
Whether the span is currently running.
- #set_meta(value) ⇒ Object
Methods included from Concerns::Durationable
Methods included from Concerns::Identifiable
Constructor Details
#initialize(type:, arguments:, logger: Logger.new) ⇒ Span
Returns a new instance of Span.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/regent/span.rb', line 27 def initialize(type:, arguments:, logger: Logger.new) super() validate_type!(type) @logger = logger @type = type @arguments = arguments @meta = nil @output = nil end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
39 40 41 |
# File 'lib/regent/span.rb', line 39 def arguments @arguments end |
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
39 40 41 |
# File 'lib/regent/span.rb', line 39 def end_time @end_time end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
39 40 41 |
# File 'lib/regent/span.rb', line 39 def name @name end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
39 40 41 |
# File 'lib/regent/span.rb', line 39 def output @output end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
39 40 41 |
# File 'lib/regent/span.rb', line 39 def start_time @start_time end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
39 40 41 |
# File 'lib/regent/span.rb', line 39 def type @type end |
Instance Method Details
#completed? ⇒ Boolean
Returns Whether the span is completed.
64 65 66 |
# File 'lib/regent/span.rb', line 64 def completed? @start_time && @end_time end |
#replay ⇒ String
Returns The output of the span.
54 55 56 |
# File 'lib/regent/span.rb', line 54 def replay log_operation(live: false) { @output } end |
#run ⇒ String
Returns The output of the span.
43 44 45 46 47 48 49 50 51 |
# File 'lib/regent/span.rb', line 43 def run @output = log_operation do yield rescue StandardError, ToolError => e logger.error(label: type, message: e., **arguments) raise end end |
#running? ⇒ Boolean
Returns Whether the span is currently running.
59 60 61 |
# File 'lib/regent/span.rb', line 59 def running? @start_time && @end_time.nil? end |
#set_meta(value) ⇒ Object
69 70 71 |
# File 'lib/regent/span.rb', line 69 def (value) @meta = value.freeze end |