Class: LittleGhost::Instrumentation::Handle
- Inherits:
-
Object
- Object
- LittleGhost::Instrumentation::Handle
- Defined in:
- lib/little_ghost/instrumentation.rb
Overview
A Handle represents work between Instrumentation.start and #finish.
Non-detached handles are fiber-owned and must finish in LIFO order after their children. Detached handles may finish outside the creating fiber but still cannot finish while local children remain active.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Operation identity, inherited attributes, previous local handle, and monotonic start time.
-
#operation_id ⇒ Object
readonly
Operation identity, inherited attributes, previous local handle, and monotonic start time.
-
#parent_operation_id ⇒ Object
readonly
Operation identity, inherited attributes, previous local handle, and monotonic start time.
-
#payload ⇒ Object
readonly
Operation identity, inherited attributes, previous local handle, and monotonic start time.
-
#previous ⇒ Object
readonly
Operation identity, inherited attributes, previous local handle, and monotonic start time.
-
#started_at ⇒ Object
readonly
Operation identity, inherited attributes, previous local handle, and monotonic start time.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Indicates whether this handle is still active.
-
#detached? ⇒ Boolean
Indicates whether this handle is outside the fiber-local operation stack.
-
#finish(**attributes) ⇒ Object
Completes this operation with additional attributes.
-
#initialize(bus, name, operation_id:, parent_operation_id:, local_parent:, previous:, payload:, started_at:, detached:) ⇒ Handle
constructor
:nodoc:.
-
#local_parent? ⇒ Boolean
Indicates whether the parent is another active handle on this bus.
-
#owner? ⇒ Boolean
Indicates whether this handle belongs to the current fiber.
Constructor Details
#initialize(bus, name, operation_id:, parent_operation_id:, local_parent:, previous:, payload:, started_at:, detached:) ⇒ Handle
:nodoc:
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/little_ghost/instrumentation.rb', line 62 def initialize(bus, name, operation_id:, parent_operation_id:, local_parent:, previous:, payload:, started_at:, detached:) # :nodoc: @bus = bus @name = name.to_sym @operation_id = operation_id @parent_operation_id = parent_operation_id @local_parent = local_parent @previous = previous @payload = payload @started_at = started_at @detached = detached @owner = Fiber.current end |
Instance Attribute Details
#name ⇒ Object (readonly)
Operation identity, inherited attributes, previous local handle, and monotonic start time.
60 61 62 |
# File 'lib/little_ghost/instrumentation.rb', line 60 def name @name end |
#operation_id ⇒ Object (readonly)
Operation identity, inherited attributes, previous local handle, and monotonic start time.
60 61 62 |
# File 'lib/little_ghost/instrumentation.rb', line 60 def operation_id @operation_id end |
#parent_operation_id ⇒ Object (readonly)
Operation identity, inherited attributes, previous local handle, and monotonic start time.
60 61 62 |
# File 'lib/little_ghost/instrumentation.rb', line 60 def parent_operation_id @parent_operation_id end |
#payload ⇒ Object (readonly)
Operation identity, inherited attributes, previous local handle, and monotonic start time.
60 61 62 |
# File 'lib/little_ghost/instrumentation.rb', line 60 def payload @payload end |
#previous ⇒ Object (readonly)
Operation identity, inherited attributes, previous local handle, and monotonic start time.
60 61 62 |
# File 'lib/little_ghost/instrumentation.rb', line 60 def previous @previous end |
#started_at ⇒ Object (readonly)
Operation identity, inherited attributes, previous local handle, and monotonic start time.
60 61 62 |
# File 'lib/little_ghost/instrumentation.rb', line 60 def started_at @started_at end |
Instance Method Details
#active? ⇒ Boolean
Indicates whether this handle is still active.
87 |
# File 'lib/little_ghost/instrumentation.rb', line 87 def active? = @bus.active?(self) |
#detached? ⇒ Boolean
Indicates whether this handle is outside the fiber-local operation stack.
83 84 |
# File 'lib/little_ghost/instrumentation.rb', line 83 def detached? = @detached # Indicates whether the parent is another active handle on this bus. |
#finish(**attributes) ⇒ Object
Completes this operation with additional attributes.
76 77 78 |
# File 'lib/little_ghost/instrumentation.rb', line 76 def finish(**attributes) @bus.finish(self, **attributes) end |
#local_parent? ⇒ Boolean
Indicates whether the parent is another active handle on this bus.
85 86 |
# File 'lib/little_ghost/instrumentation.rb', line 85 def local_parent? = @local_parent # Indicates whether this handle is still active. |
#owner? ⇒ Boolean
Indicates whether this handle belongs to the current fiber.
81 82 |
# File 'lib/little_ghost/instrumentation.rb', line 81 def owner? = @owner.equal?(Fiber.current) # Indicates whether this handle is outside the fiber-local operation stack. |