Class: NextStation::Logging::Subscribers::Step Private

Inherits:
Base
  • Object
show all
Defined in:
lib/next_station/logging/subscribers/step.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 step lifecycle events.

Constant Summary

Constants inherited from Base

Base::LEVELS

Instance Method Summary collapse

Methods inherited from Base

subscribe

Instance Method Details

#on_retry(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.

Parameters:

  • event (Dry::Monitor::Event)


42
43
44
45
46
47
48
49
50
# File 'lib/next_station/logging/subscribers/step.rb', line 42

def on_retry(event)
  log_event(event, level: :warn, extra_data: {
    message: "Retrying step: #{event[:step]} (attempt #{event[:attempt]})",
    event_kind: 'step.retry',
    step_name: event[:step],
    operation: event[:operation],
    step_attempt: event[:attempt]
  })
end

#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.

Parameters:

  • event (Dry::Monitor::Event)


19
20
21
22
23
24
25
26
# File 'lib/next_station/logging/subscribers/step.rb', line 19

def on_start(event)
  log_event(event, level: :debug, extra_data: {
    message: "Started step: #{event[:step]} in #{event[:operation]}",
    event_kind: 'step.start',
    step_name: event[:step],
    operation: event[:operation]
  })
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.

Parameters:

  • event (Dry::Monitor::Event)


29
30
31
32
33
34
35
36
37
38
39
# File 'lib/next_station/logging/subscribers/step.rb', line 29

def on_stop(event)
  log_event(event, level: :debug, extra_data: {
    message: "Completed step: #{event[:step]} in #{event[:operation]}",
    event_kind: 'step.stop',
    step_name: event[:step],
    operation: event[:operation],
    payload: {
      duration: event[:duration]
    }
  })
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.

Parameters:

  • monitor (Dry::Monitor::Notifications)


12
13
14
15
16
# File 'lib/next_station/logging/subscribers/step.rb', line 12

def subscribe(monitor)
  monitor.subscribe('step.start') { |event| on_start(event) }
  monitor.subscribe('step.stop') { |event| on_stop(event) }
  monitor.subscribe('step.retry') { |event| on_retry(event) }
end