Class: Tpt::Rails::Config
- Inherits:
-
Object
- Object
- Tpt::Rails::Config
- Defined in:
- lib/tpt/rails/config.rb
Instance Attribute Summary collapse
-
#app_env ⇒ Object
E.g.
-
#app_name ⇒ Object
E.g.
-
#bugsnag_api_key ⇒ Object
A project-specific api key from Bugsnag.
-
#datadog_statsd_url ⇒ Object
Set this in the form of: statsd://:[port]‘.
-
#datadog_trace_url ⇒ Object
Set this in the form of: datadog://:[port]‘.
-
#health_checks ⇒ Object
readonly
Internal code.
-
#redis_url ⇒ Object
Set this in the form of: redis://:@[hostname]:/[db].
-
#rollbar_access_token ⇒ Object
A project-specific access token from rollbar.
-
#rollbar_enabled ⇒ Object
Allow enabling/disabling Rollbar.
Instance Method Summary collapse
-
#health_check(name, &block) ⇒ Object
Add a health check to the endpoint provided at ‘/internal/health-check` by Tpt::Rails::HealthChecksController.
-
#initialize ⇒ Config
constructor
:nodoc:.
-
#report(error) ⇒ Object
:nodoc:.
-
#setup ⇒ Object
:nodoc:.
-
#statsd ⇒ Object
:nodoc:.
Constructor Details
Instance Attribute Details
#app_env ⇒ Object
E.g. production/integration/jordan123
11 12 13 |
# File 'lib/tpt/rails/config.rb', line 11 def app_env @app_env end |
#app_name ⇒ Object
E.g. earnings/resource-write/tpt-data
13 14 15 |
# File 'lib/tpt/rails/config.rb', line 13 def app_name @app_name end |
#bugsnag_api_key ⇒ Object
A project-specific api key from Bugsnag
15 16 17 |
# File 'lib/tpt/rails/config.rb', line 15 def bugsnag_api_key @bugsnag_api_key end |
#datadog_statsd_url ⇒ Object
Set this in the form of: statsd://:[port]‘
17 18 19 |
# File 'lib/tpt/rails/config.rb', line 17 def datadog_statsd_url @datadog_statsd_url end |
#datadog_trace_url ⇒ Object
Set this in the form of: datadog://:[port]‘
19 20 21 |
# File 'lib/tpt/rails/config.rb', line 19 def datadog_trace_url @datadog_trace_url end |
#health_checks ⇒ Object (readonly)
Internal code
44 45 46 |
# File 'lib/tpt/rails/config.rb', line 44 def health_checks @health_checks end |
#redis_url ⇒ Object
Set this in the form of: redis://:@[hostname]:/[db]
21 22 23 |
# File 'lib/tpt/rails/config.rb', line 21 def redis_url @redis_url end |
#rollbar_access_token ⇒ Object
A project-specific access token from rollbar
23 24 25 |
# File 'lib/tpt/rails/config.rb', line 23 def @rollbar_access_token end |
#rollbar_enabled ⇒ Object
Allow enabling/disabling Rollbar. Defaults to false.
25 26 27 |
# File 'lib/tpt/rails/config.rb', line 25 def @rollbar_enabled end |
Instance Method Details
#health_check(name, &block) ⇒ Object
Add a health check to the endpoint provided at ‘/internal/health-check` by Tpt::Rails::HealthChecksController.
The block provided to this method should return a truthy/falsey value for success/failure.
Example:
config.health_check(:foo) { 'foo' == 'foo' }
36 37 38 |
# File 'lib/tpt/rails/config.rb', line 36 def health_check(name, &block) @health_checks.add(name, &block) end |
#report(error) ⇒ Object
:nodoc:
77 78 79 |
# File 'lib/tpt/rails/config.rb', line 77 def report(error) # :nodoc: @error_reporter.report(error) end |
#setup ⇒ Object
:nodoc:
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/tpt/rails/config.rb', line 50 def setup # :nodoc: if redis_url # Ensure that redis has been added to the app's Gemfile if a `redis_url` has been set gem 'redis', '>= 4', '< 5' gem 'hiredis' Redis.current = Redis.new(url: redis_url, driver: :hiredis) end @datadog = Tpt::Rails::Internal::Datadog.new( statsd_url: datadog_statsd_url, trace_url: datadog_trace_url, ) @health_checks.setup @error_reporter = Tpt::Rails::Internal::ErrorReporter.new( bugsnag_api_key: bugsnag_api_key.presence, rollbar_access_token: .presence, rollbar_enabled: ? true : false, ) end |
#statsd ⇒ Object
:nodoc:
73 74 75 |
# File 'lib/tpt/rails/config.rb', line 73 def statsd # :nodoc: @datadog.statsd end |