Module: Easyop::Plugins::Recording::RunWrapper

Defined in:
lib/easyop/plugins/recording.rb

Instance Method Summary collapse

Instance Method Details

#_easyop_run(ctx, raise_on_failure:) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/easyop/plugins/recording.rb', line 68

def _easyop_run(ctx, raise_on_failure:)
  return super unless self.class._recording_enabled?
  return super unless (model = self.class._recording_model)
  return super unless self.class.name # skip anonymous classes

  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  super
ensure
  # Always record — including when raise_on_failure: true raises Ctx::Failure
  # (e.g. when this operation is a step inside a Flow). Without the ensure
  # branch the tap block would be skipped and failures inside flows would
  # never be persisted.
  if start
    ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).round(2)
    _recording_persist!(ctx, model, ms)
  end
end