Class: RailsPulse::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_pulse/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/rails_pulse/configuration.rb', line 37

def initialize
  @enabled = true
  @route_thresholds = { slow: 500, very_slow: 1500, critical: 3000 }
  @request_thresholds = { slow: 700, very_slow: 2000, critical: 4000 }
  @query_thresholds = { slow: 100, very_slow: 500, critical: 1000 }
  @job_thresholds = { slow: 5_000, very_slow: 30_000, critical: 60_000 }
  @ignored_routes = []
  @ignored_requests = []
  @ignored_queries = []
  @ignored_jobs = []
  @ignored_queues = []
  @track_assets = false
  @track_jobs = false
  @custom_asset_patterns = []
  @mount_path = nil
  @full_retention_period = 30.days
  @archiving_enabled = true
  @max_table_records = {
    rails_pulse_operations: 100_000,
    rails_pulse_requests: 50_000,
    rails_pulse_job_runs: 50_000,
    rails_pulse_queries: 10_000,
    rails_pulse_routes: 1_000,
    rails_pulse_jobs: 1_000
  }
  @connects_to = nil
  @authentication_enabled = Rails.env.production?
  @authentication_method = nil
  @authentication_redirect_path = "/"
  @tags = [ "ignored", "critical", "experimental" ]
  @job_tracking_mode = :universal
  @job_adapters = {
    sidekiq: { enabled: true, track_queue_depth: false },
    solid_queue: { enabled: true, track_recurring: false },
    good_job: { enabled: true, track_cron: false },
    delayed_job: { enabled: true },
    resque: { enabled: true }
  }
  @capture_job_arguments = false

  # Dashboard settings
  @mount_dashboard = true
  @logger = nil

  # Tracking mode settings
  @async = true

  # Service Level Objectives (default: [] = no SLOs configured)
  @service_level_objectives = []
  @query_service_level_objectives = []

  # Show a warning banner when summaries haven't been generated recently
  @warn_on_stale_summaries = true

  # Validate defaults eagerly so that a misconfigured initializer raises at
  # boot time rather than at the first request. All SLO defaults are nil so
  # validation short-circuits harmlessly here; it becomes meaningful when
  # RailsPulse.configure yields and sets real values.
  validate_configuration!
end

Instance Attribute Details

#archiving_enabledObject

Returns the value of attribute archiving_enabled.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def archiving_enabled
  @archiving_enabled
end

#asyncObject

Returns the value of attribute async.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def async
  @async
end

#authentication_enabledObject

Returns the value of attribute authentication_enabled.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def authentication_enabled
  @authentication_enabled
end

#authentication_methodObject

Returns the value of attribute authentication_method.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def authentication_method
  @authentication_method
end

#authentication_redirect_pathObject

Returns the value of attribute authentication_redirect_path.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def authentication_redirect_path
  @authentication_redirect_path
end

#capture_job_argumentsObject

Returns the value of attribute capture_job_arguments.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def capture_job_arguments
  @capture_job_arguments
end

#connects_toObject

Returns the value of attribute connects_to.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def connects_to
  @connects_to
end

#custom_asset_patternsObject

Returns the value of attribute custom_asset_patterns.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def custom_asset_patterns
  @custom_asset_patterns
end

#enabledObject

Returns the value of attribute enabled.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def enabled
  @enabled
end

#full_retention_periodObject

Returns the value of attribute full_retention_period.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def full_retention_period
  @full_retention_period
end

#ignored_jobsObject

Returns the value of attribute ignored_jobs.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def ignored_jobs
  @ignored_jobs
end

#ignored_queriesObject

Returns the value of attribute ignored_queries.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def ignored_queries
  @ignored_queries
end

#ignored_queuesObject

Returns the value of attribute ignored_queues.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def ignored_queues
  @ignored_queues
end

#ignored_requestsObject

Returns the value of attribute ignored_requests.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def ignored_requests
  @ignored_requests
end

#ignored_routesObject

Get all routes to ignore, including asset patterns if track_assets is false



121
122
123
# File 'lib/rails_pulse/configuration.rb', line 121

def ignored_routes
  @ignored_routes
end

#job_adaptersObject

Returns the value of attribute job_adapters.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def job_adapters
  @job_adapters
end

#job_thresholdsObject

Read-only access to thresholds (use setters for validation)



32
33
34
# File 'lib/rails_pulse/configuration.rb', line 32

def job_thresholds
  @job_thresholds
end

#job_tracking_modeObject

Returns the value of attribute job_tracking_mode.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def job_tracking_mode
  @job_tracking_mode
end

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def logger
  @logger
end

#max_table_recordsObject

Returns the value of attribute max_table_records.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def max_table_records
  @max_table_records
end

#mount_dashboardObject

Returns the value of attribute mount_dashboard.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def mount_dashboard
  @mount_dashboard
end

#mount_pathObject

Returns the value of attribute mount_path.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def mount_path
  @mount_path
end

#query_service_level_objectivesObject

Returns the value of attribute query_service_level_objectives.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def query_service_level_objectives
  @query_service_level_objectives
end

#query_thresholdsObject

Read-only access to thresholds (use setters for validation)



32
33
34
# File 'lib/rails_pulse/configuration.rb', line 32

def query_thresholds
  @query_thresholds
end

#request_thresholdsObject

Read-only access to thresholds (use setters for validation)



32
33
34
# File 'lib/rails_pulse/configuration.rb', line 32

def request_thresholds
  @request_thresholds
end

#route_thresholdsObject

Read-only access to thresholds (use setters for validation)



32
33
34
# File 'lib/rails_pulse/configuration.rb', line 32

def route_thresholds
  @route_thresholds
end

#service_level_objectivesObject

Returns the value of attribute service_level_objectives.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def service_level_objectives
  @service_level_objectives
end

#tagsObject

Returns the value of attribute tags.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def tags
  @tags
end

#track_assetsObject

Returns the value of attribute track_assets.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def track_assets
  @track_assets
end

#track_jobsObject

Returns the value of attribute track_jobs.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def track_jobs
  @track_jobs
end

#warn_on_stale_summariesObject

Returns the value of attribute warn_on_stale_summaries.



3
4
5
# File 'lib/rails_pulse/configuration.rb', line 3

def warn_on_stale_summaries
  @warn_on_stale_summaries
end

Instance Method Details

#validate_configuration!Object

Validate configuration settings



133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/rails_pulse/configuration.rb', line 133

def validate_configuration!
  validate_thresholds!
  validate_retention_settings!
  validate_patterns!
  validate_database_settings!
  validate_authentication_settings!
  validate_tags!
  validate_job_settings!
  validate_dashboard_settings!
  validate_tracking_settings!
  validate_service_level_objectives_settings!
  validate_query_service_level_objectives_settings!
end