Class: LittleGhost::Instrumentation::Handle

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#nameObject (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_idObject (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_idObject (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

#payloadObject (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

#previousObject (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_atObject (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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.