Class: NextStation::Logging::Subscribers::Operation Private
- Defined in:
- lib/next_station/logging/subscribers/operation.rb
Overview
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.
Subscriber for operation lifecycle events.
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
- #on_start(event) ⇒ Object private
- #on_stop(event) ⇒ Object private
- #subscribe(monitor) ⇒ Object private
Methods inherited from Base
Instance Method Details
#on_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.
18 19 20 21 22 23 |
# File 'lib/next_station/logging/subscribers/operation.rb', line 18 def on_start(event) log_event(event, extra_data: { message: "Started operation: #{event[:operation]}", event_kind: 'operation.start' }) end |
#on_stop(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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/next_station/logging/subscribers/operation.rb', line 26 def on_stop(event) result_status = event[:result].success? ? 'success' : 'failure' result_error_type = event[:result].error&.type if event[:result].failure? payload = {} payload[:duration] = event[:duration] payload[:result] = result_status payload[:error_type] = result_error_type.to_s if result_error_type log_event(event, extra_data: { message: "completed operation: #{event[:operation]} with #{result_status}", event_kind: 'operation.stop', payload: payload }) end |
#subscribe(monitor) ⇒ 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.
12 13 14 15 |
# File 'lib/next_station/logging/subscribers/operation.rb', line 12 def subscribe(monitor) monitor.subscribe('operation.start') { |event| on_start(event) } monitor.subscribe('operation.stop') { |event| on_stop(event) } end |