Module: Easyop::Plugins::Recording

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

Overview

Records operation executions to a database model.

Usage:

class ApplicationOperation
  include Easyop::Operation
  plugin Easyop::Plugins::Recording, model: OperationLog
end

Required model columns (create with the generator migration):

operation_name  :string,   null: false
success         :boolean,  null: false
error_message   :string
params_data     :text               # stored as JSON
duration_ms     :float
performed_at    :datetime, null: false

Optional flow-tracing columns:

root_reference_id     :string   # shared across entire execution tree
reference_id          :string   # unique to this operation execution
parent_operation_name :string   # class name of the direct parent
parent_reference_id   :string   # reference_id of the direct parent

Optional result column:

result_data           :text     # stored as JSON — selected ctx keys after call

Opt out per operation class:

class MyOp < ApplicationOperation
  recording false
end

Options:

model:         (required) ActiveRecord class
record_params: true       pass false to skip params serialization
record_result: nil        configure result capture at plugin level (Hash/Proc/Symbol)

Defined Under Namespace

Modules: ClassMethods, RunWrapper

Constant Summary collapse

SCRUBBED_KEYS =

Sensitive keys scrubbed from params_data before persisting.

%i[password password_confirmation token secret api_key].freeze
INTERNAL_CTX_KEYS =

Internal ctx keys used for flow tracing — excluded from params_data.

%i[
  __recording_root_reference_id
  __recording_parent_operation_name
  __recording_parent_reference_id
].freeze

Class Method Summary collapse

Class Method Details

.install(base, model:, record_params: true, record_result: nil, **_options) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/easyop/plugins/recording.rb', line 52

def self.install(base, model:, record_params: true, record_result: nil, **_options)
  base.extend(ClassMethods)
  base.prepend(RunWrapper)
  base.instance_variable_set(:@_recording_model,         model)
  base.instance_variable_set(:@_recording_record_params,  record_params)
  base.instance_variable_set(:@_recording_record_result,  record_result)
end