Class: Tracebook::Config
- Inherits:
-
Object
- Object
- Tracebook::Config
- Defined in:
- lib/tracebook/config.rb
Overview
Configuration object for TraceBook.
Contains all configurable options for the TraceBook engine. Configuration is frozen after the configure block executes to prevent runtime modifications.
Instance Attribute Summary collapse
-
#auto_subscribe_active_agent ⇒ Boolean
Auto-enable ActiveAgent adapter on boot (default: false).
-
#auto_subscribe_ruby_llm ⇒ Boolean
Auto-enable RubyLLM adapter on boot (default: false).
-
#custom_redactors ⇒ Array<Proc>
Additional user-defined redactors that receive the payload string and return a redacted version.
-
#default_currency ⇒ String
Used in PricingRule cost tracking.
-
#export_formats ⇒ Array<Symbol>
Supported formats for ExportJob.
-
#inline_payload_bytes ⇒ Integer
Payloads larger than this threshold are stored as ActiveStorage blobs instead of inline JSONB columns.
-
#per_page ⇒ Integer
Number of interactions per page in dashboard (default: 100).
-
#persist_async ⇒ Boolean
When true, record! enqueues PersistInteractionJob.
-
#project_name ⇒ String?
Used to filter interactions by project in the dashboard.
-
#redactors ⇒ Array<Redactor>
Default redactors for email, phone, credit card numbers.
Instance Method Summary collapse
- #default_redactors ⇒ Object private
-
#finalize! ⇒ void
Freezes the configuration to prevent further changes.
-
#finalized? ⇒ Boolean
Returns true if configuration has been finalized.
- #freeze_collections! ⇒ Object private
-
#initialize ⇒ Config
constructor
Creates a new configuration with default values.
Constructor Details
#initialize ⇒ Config
Creates a new configuration with default values.
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/tracebook/config.rb', line 84 def initialize @project_name = nil @persist_async = true @inline_payload_bytes = 64 * 1024 @default_currency = "USD" @export_formats = [ :csv, :ndjson ] @redactors = default_redactors @custom_redactors = [] @auto_subscribe_ruby_llm = false @auto_subscribe_active_agent = false @per_page = 100 end |
Instance Attribute Details
#auto_subscribe_active_agent ⇒ Boolean
Returns Auto-enable ActiveAgent adapter on boot (default: false).
75 76 77 |
# File 'lib/tracebook/config.rb', line 75 def auto_subscribe_active_agent @auto_subscribe_active_agent end |
#auto_subscribe_ruby_llm ⇒ Boolean
Returns Auto-enable RubyLLM adapter on boot (default: false).
71 72 73 |
# File 'lib/tracebook/config.rb', line 71 def auto_subscribe_ruby_llm @auto_subscribe_ruby_llm end |
#custom_redactors ⇒ Array<Proc>
Additional user-defined redactors that receive the payload string and return a redacted version.
67 68 69 |
# File 'lib/tracebook/config.rb', line 67 def custom_redactors @custom_redactors end |
#default_currency ⇒ String
Used in PricingRule cost tracking
46 47 48 |
# File 'lib/tracebook/config.rb', line 46 def default_currency @default_currency end |
#export_formats ⇒ Array<Symbol>
Supported formats for ExportJob
51 52 53 |
# File 'lib/tracebook/config.rb', line 51 def export_formats @export_formats end |
#inline_payload_bytes ⇒ Integer
Payloads larger than this threshold are stored as ActiveStorage blobs instead of inline JSONB columns.
41 42 43 |
# File 'lib/tracebook/config.rb', line 41 def inline_payload_bytes @inline_payload_bytes end |
#per_page ⇒ Integer
Returns Number of interactions per page in dashboard (default: 100).
79 80 81 |
# File 'lib/tracebook/config.rb', line 79 def per_page @per_page end |
#persist_async ⇒ Boolean
When true, Tracebook.record! enqueues PersistInteractionJob. When false, interactions are persisted inline.
35 36 37 |
# File 'lib/tracebook/config.rb', line 35 def persist_async @persist_async end |
#project_name ⇒ String?
Used to filter interactions by project in the dashboard
29 30 31 |
# File 'lib/tracebook/config.rb', line 29 def project_name @project_name end |
#redactors ⇒ Array<Redactor>
Default redactors for email, phone, credit card numbers. See Redactors::Email, Redactors::Phone, Redactors::CardPAN
57 58 59 |
# File 'lib/tracebook/config.rb', line 57 def redactors @redactors end |
Instance Method Details
#default_redactors ⇒ Object (private)
119 120 121 122 123 124 125 |
# File 'lib/tracebook/config.rb', line 119 def default_redactors [ Tracebook::Redactors::Email.new, Tracebook::Redactors::Phone.new, Tracebook::Redactors::CardPAN.new ] end |
#finalize! ⇒ void
This method returns an undefined value.
Freezes the configuration to prevent further changes.
Called automatically by Tracebook.configure after the block executes.
109 110 111 112 113 114 115 |
# File 'lib/tracebook/config.rb', line 109 def finalize! return if finalized? @finalized = true freeze_collections! freeze end |
#finalized? ⇒ Boolean
Returns true if configuration has been finalized.
100 101 102 |
# File 'lib/tracebook/config.rb', line 100 def finalized? @finalized == true end |
#freeze_collections! ⇒ Object (private)
127 128 129 130 131 |
# File 'lib/tracebook/config.rb', line 127 def freeze_collections! @redactors = @redactors.map { |redactor| redactor }.freeze @custom_redactors = @custom_redactors.map { |callable| callable }.freeze @export_formats = @export_formats.map(&:to_sym).freeze end |