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

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

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

Class Method Summary collapse

Class Method Details

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



33
34
35
36
37
38
# File 'lib/easyop/plugins/recording.rb', line 33

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