Class: Hoss::Instrumenter Private
- Inherits:
-
Object
- Object
- Hoss::Instrumenter
- Includes:
- Logging
- Defined in:
- lib/hoss/instrumenter.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Current
Constant Summary collapse
- EVENT_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:__elastic_instrumenter_events_key
Constants included from Logging
Logging::LEVELS, Logging::PREFIX
Instance Attribute Summary collapse
- #enqueue ⇒ Object readonly private
- #stacktrace_builder ⇒ Object readonly private
Instance Method Summary collapse
- #current_event ⇒ Object private
-
#current_events ⇒ Object
private
events.
- #end_event ⇒ Object private
- #handle_forking! ⇒ Object private
-
#initialize(config, metrics:, stacktrace_builder:, &enqueue) ⇒ Instrumenter
constructor
private
A new instance of Instrumenter.
- #start ⇒ Object private
- #start_event ⇒ Object private
- #stop ⇒ Object private
- #subscriber=(subscriber) ⇒ Object private
Methods included from Logging
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(config, metrics:, stacktrace_builder:, &enqueue) ⇒ Instrumenter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Instrumenter.
46 47 48 49 50 51 52 53 |
# File 'lib/hoss/instrumenter.rb', line 46 def initialize(config, metrics:, stacktrace_builder:, &enqueue) @config = config @stacktrace_builder = stacktrace_builder @enqueue = enqueue @metrics = metrics @current = Current.new end |
Instance Attribute Details
#enqueue ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/hoss/instrumenter.rb', line 55 def enqueue @enqueue end |
#stacktrace_builder ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/hoss/instrumenter.rb', line 55 def stacktrace_builder @stacktrace_builder end |
Instance Method Details
#current_event ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
90 91 92 |
# File 'lib/hoss/instrumenter.rb', line 90 def current_event current_events.last end |
#current_events ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
events
86 87 88 |
# File 'lib/hoss/instrumenter.rb', line 86 def current_events @current.events end |
#end_event ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
100 101 102 103 104 105 |
# File 'lib/hoss/instrumenter.rb', line 100 def end_event return unless (event = current_events.pop) event.done enqueue.call event event end |
#handle_forking! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
72 73 74 75 |
# File 'lib/hoss/instrumenter.rb', line 72 def handle_forking! stop start end |
#start ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 60 61 62 |
# File 'lib/hoss/instrumenter.rb', line 57 def start debug 'Starting instrumenter' # We call register! on @subscriber in case the # instrumenter was stopped and started again @subscriber&.register! end |
#start_event ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
94 95 96 97 98 |
# File 'lib/hoss/instrumenter.rb', line 94 def start_event event = Event.new current_events.push event event.start end |
#stop ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 67 68 69 70 |
# File 'lib/hoss/instrumenter.rb', line 64 def stop debug 'Stopping instrumenter' current_events.pop until current_events.empty? @subscriber&.unregister! end |
#subscriber=(subscriber) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
77 78 79 80 81 |
# File 'lib/hoss/instrumenter.rb', line 77 def subscriber=(subscriber) debug 'Registering subscriber' @subscriber = subscriber @subscriber.register! end |