Class: Bugwatch::Configuration
- Inherits:
-
Object
- Object
- Bugwatch::Configuration
- Defined in:
- lib/bugwatch/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#app_version ⇒ Object
Returns the value of attribute app_version.
-
#db_query_threshold_ms ⇒ Object
Returns the value of attribute db_query_threshold_ms.
-
#db_sample_rate ⇒ Object
Returns the value of attribute db_sample_rate.
-
#enable_db_tracking ⇒ Object
Returns the value of attribute enable_db_tracking.
-
#enable_performance_tracking ⇒ Object
Returns the value of attribute enable_performance_tracking.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#ignore_classes ⇒ Object
Returns the value of attribute ignore_classes.
-
#ignore_request_paths ⇒ Object
Returns the value of attribute ignore_request_paths.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_queries_per_request ⇒ Object
Returns the value of attribute max_queries_per_request.
-
#notify_release_stages ⇒ Object
Returns the value of attribute notify_release_stages.
-
#release_stage ⇒ Object
Returns the value of attribute release_stage.
-
#sample_rate ⇒ Object
Returns the value of attribute sample_rate.
Instance Method Summary collapse
- #ignore?(exception) ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #notify_for_release_stage? ⇒ Boolean
- #track_request?(path) ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bugwatch/configuration.rb', line 18 def initialize @endpoint = nil @release_stage = "production" @notify_release_stages = ["production"] @ignore_classes = [] @logger = Logger.new($stdout) if defined?(Logger) @enable_performance_tracking = true @sample_rate = 1.0 @ignore_request_paths = [] @enable_db_tracking = true @db_sample_rate = 1.0 @db_query_threshold_ms = 0.0 @max_queries_per_request = 200 end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def api_key @api_key end |
#app_version ⇒ Object
Returns the value of attribute app_version.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def app_version @app_version end |
#db_query_threshold_ms ⇒ Object
Returns the value of attribute db_query_threshold_ms.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def db_query_threshold_ms @db_query_threshold_ms end |
#db_sample_rate ⇒ Object
Returns the value of attribute db_sample_rate.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def db_sample_rate @db_sample_rate end |
#enable_db_tracking ⇒ Object
Returns the value of attribute enable_db_tracking.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def enable_db_tracking @enable_db_tracking end |
#enable_performance_tracking ⇒ Object
Returns the value of attribute enable_performance_tracking.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def enable_performance_tracking @enable_performance_tracking end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def endpoint @endpoint end |
#ignore_classes ⇒ Object
Returns the value of attribute ignore_classes.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def ignore_classes @ignore_classes end |
#ignore_request_paths ⇒ Object
Returns the value of attribute ignore_request_paths.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def ignore_request_paths @ignore_request_paths end |
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def logger @logger end |
#max_queries_per_request ⇒ Object
Returns the value of attribute max_queries_per_request.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def max_queries_per_request @max_queries_per_request end |
#notify_release_stages ⇒ Object
Returns the value of attribute notify_release_stages.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def notify_release_stages @notify_release_stages end |
#release_stage ⇒ Object
Returns the value of attribute release_stage.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def release_stage @release_stage end |
#sample_rate ⇒ Object
Returns the value of attribute sample_rate.
3 4 5 |
# File 'lib/bugwatch/configuration.rb', line 3 def sample_rate @sample_rate end |
Instance Method Details
#ignore?(exception) ⇒ Boolean
37 38 39 40 41 42 43 44 |
# File 'lib/bugwatch/configuration.rb', line 37 def ignore?(exception) ignore_classes.any? do |klass| klass = Object.const_get(klass) if klass.is_a?(String) exception.is_a?(klass) rescue NameError false end end |
#notify_for_release_stage? ⇒ Boolean
33 34 35 |
# File 'lib/bugwatch/configuration.rb', line 33 def notify_for_release_stage? notify_release_stages.include?(release_stage.to_s) end |
#track_request?(path) ⇒ Boolean
46 47 48 49 50 51 |
# File 'lib/bugwatch/configuration.rb', line 46 def track_request?(path) return false unless enable_performance_tracking return false if ignore_request_paths.any? { |pattern| path.match?(pattern) } return false if sample_rate < 1.0 && rand > sample_rate true end |