Class: Errsight::Configuration
- Inherits:
-
Object
- Object
- Errsight::Configuration
- Defined in:
- lib/errsight/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#attach_to_rails_logger ⇒ Object
Returns the value of attribute attach_to_rails_logger.
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#before_send ⇒ Object
Returns the value of attribute before_send.
-
#breadcrumbs_active_record ⇒ Object
Returns the value of attribute breadcrumbs_active_record.
-
#breadcrumbs_active_record_capture_binds ⇒ Object
Returns the value of attribute breadcrumbs_active_record_capture_binds.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_queue_size ⇒ Object
Returns the value of attribute max_queue_size.
-
#min_level ⇒ Object
Returns the value of attribute min_level.
-
#release ⇒ Object
Returns the value of attribute release.
-
#shutdown_timeout ⇒ Object
Returns the value of attribute shutdown_timeout.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
- #events_endpoint ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/errsight/configuration.rb', line 9 def initialize @api_key = ENV["ERRSIGHT_API_KEY"] @environment = ENV.fetch("ERRSIGHT_ENV", "production") @min_level = :warning @host = ENV.fetch("ERRSIGHT_HOST", "https://errsight.com") @timeout = 5 @enabled = true @batch_size = 10 @flush_interval = 2 # seconds @max_queue_size = 1_000 @logger = defined?(Rails) ? Rails.logger : Logger.new($stdout) # Off by default. When true, every Rails.logger call at min_level or # above becomes an Errsight event, which floods the issue list with # framework deprecation noise and burns customer event quota for # something that should be in their log aggregator, not their error # tracker. Customers who actually want log forwarding can opt in. @attach_to_rails_logger = false @release = ENV["ERRSIGHT_RELEASE"] @shutdown_timeout = 5 # seconds to wait for flush thread on shutdown # Auto-collect SQL queries as breadcrumbs via the sql.active_record # notification. Default on — this is the headline Rails feature. # Customers with extreme-query-volume workloads can disable. @breadcrumbs_active_record = true # Bind values can carry PII (emails, tokens, customer IDs) so we ship # the parameterized SQL only by default. Compliance-relaxed customers # opt in. @breadcrumbs_active_record_capture_binds = false # Per-event filter. Receives the event hash, must return a (possibly # modified) hash to send, or nil to drop. Used by compliance teams to # scrub PII, by ops teams to drop noisy errors, and by anyone who # wants final-mile control before events leave the process. @before_send = nil end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def api_key @api_key end |
#attach_to_rails_logger ⇒ Object
Returns the value of attribute attach_to_rails_logger.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def attach_to_rails_logger @attach_to_rails_logger end |
#batch_size ⇒ Object
Returns the value of attribute batch_size.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def batch_size @batch_size end |
#before_send ⇒ Object
Returns the value of attribute before_send.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def before_send @before_send end |
#breadcrumbs_active_record ⇒ Object
Returns the value of attribute breadcrumbs_active_record.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def @breadcrumbs_active_record end |
#breadcrumbs_active_record_capture_binds ⇒ Object
Returns the value of attribute breadcrumbs_active_record_capture_binds.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def @breadcrumbs_active_record_capture_binds end |
#enabled ⇒ Object
Returns the value of attribute enabled.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def enabled @enabled end |
#environment ⇒ Object
Returns the value of attribute environment.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def environment @environment end |
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def flush_interval @flush_interval end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def logger @logger end |
#max_queue_size ⇒ Object
Returns the value of attribute max_queue_size.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def max_queue_size @max_queue_size end |
#min_level ⇒ Object
Returns the value of attribute min_level.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def min_level @min_level end |
#release ⇒ Object
Returns the value of attribute release.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def release @release end |
#shutdown_timeout ⇒ Object
Returns the value of attribute shutdown_timeout.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def shutdown_timeout @shutdown_timeout end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def timeout @timeout end |
Instance Method Details
#enabled? ⇒ Boolean
43 44 45 |
# File 'lib/errsight/configuration.rb', line 43 def enabled? @enabled && !api_key.nil? && !api_key.strip.empty? end |
#events_endpoint ⇒ Object
53 54 55 |
# File 'lib/errsight/configuration.rb', line 53 def events_endpoint "#{host.chomp('/')}/api/v1/events" end |
#validate! ⇒ Object
47 48 49 50 51 |
# File 'lib/errsight/configuration.rb', line 47 def validate! if api_key.nil? || api_key.strip.empty? logger&.debug("[Errsight] api_key is not set; Errsight is disabled until one is configured (set ERRSIGHT_API_KEY or config.api_key).") end end |