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
: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)
scrub_keys: [] additional keys/patterns to scrub from params_data
(Symbol, String, or Regexp — additive with SCRUBBED_KEYS)
Defined Under Namespace
Modules: ClassMethods, RunWrapper
Constant Summary collapse
- SCRUBBED_KEYS =
Sensitive keys always 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
- .install(base, model:, record_params: true, record_result: nil, scrub_keys: [], **_options) ⇒ Object
Class Method Details
.install(base, model:, record_params: true, record_result: nil, scrub_keys: [], **_options) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/easyop/plugins/recording.rb', line 54 def self.install(base, model:, record_params: true, record_result: nil, scrub_keys: [], **) 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) base.instance_variable_set(:@_recording_scrub_keys, Array(scrub_keys)) end |