module BusinessFlow # Fire ActiveSupport events for every step that's run and on errors class InstrumentedExecutor < DefaultStepExecutor def call name = flow_event_name payload = { flow: flow } ActiveSupport::Notifications.instrument(name, payload) do super end notify_errors(name, payload) end protected def notify_errors(name, payload) return unless flow.errors? ActiveSupport::Notifications.publish(name + '.error', payload) end def flow_name @flow_name ||= flow.class.instrumentation_name end def flow_event_name @flow_event_name ||= flow.class.event_name end end end