Class: RooOnRails::Checks::Papertrail::DrainExists
- Inherits:
-
EnvSpecific
- Object
- Base
- EnvSpecific
- RooOnRails::Checks::Papertrail::DrainExists
- Defined in:
- lib/roo_on_rails/checks/papertrail/drain_exists.rb
Overview
Check if a Heroku app is setup to a log drain to Papertrail
Input context
-
heroku.api_client: a connected PlatformAPI client
-
heroku.app.EnvSpecific#env: an app name.
-
papertrail.dest.host, .port
Output context:
-
papertrail.system_name.EnvSpecific#env: the drain token for this app, aka. “system name” in Papertrail. Looks like “d.uuid”.
Instance Attribute Summary
Attributes inherited from EnvSpecific
Instance Method Summary collapse
Methods inherited from EnvSpecific
Methods inherited from Base
Methods included from Helpers
Constructor Details
This class inherits a constructor from RooOnRails::Checks::EnvSpecific
Instance Method Details
#call ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/roo_on_rails/checks/papertrail/drain_exists.rb', line 28 def call # find the PT drain data = client.log_drain.list(app_name). select { |h| h['url'] =~ /papertrailapp/ } fail! "no Papertrail drain found on #{bold app_name}" if data.empty? fail! "multiple Papertrail drains found on #{bold app_name}" if data.length > 1 data = data.first fail! "app is draining to #{data['url']} instead of #{papertrail_url}" if data['url'] != papertrail_url pass "found drain setup with token #{data['token']} on #{bold app_name}" context.papertrail.system_name![env] = data['token'] end |
#fix ⇒ Object
42 43 44 |
# File 'lib/roo_on_rails/checks/papertrail/drain_exists.rb', line 42 def fix client.log_drain.create(app_name, url: papertrail_url) end |
#intro ⇒ Object
24 25 26 |
# File 'lib/roo_on_rails/checks/papertrail/drain_exists.rb', line 24 def intro 'Checking for Papertrail drain...' end |