class RooOnRails::Checks::Heroku::MetricsBridgeConfigured

Checks that the Heroku-Datadog metrics bridge is configured to accept logs from the app.

Input context

Output context:

Constants

BRIDGE_APP

Public Instance Methods

call() click to toggle source
# File lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb, line 28
def call
  config = current_config
  names = config[app_list_var].split(',')

  fail! 'Bridge does not allow this app'        unless names.include? app_name
  fail! 'Bridge lacks credentials for this app' unless config[token_var]
  fail! 'Bridge lacks tags for this app'        unless config[tags_var]

  pass "Bridge is configured for #{bold app_name}"
  context.heroku.metric_bridge_token![env] = config[token_var]
end
intro() click to toggle source
# File lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb, line 24
def intro
  'Checking whether metrics bridge is configured...'
end

Private Instance Methods

app_list_var() click to toggle source
# File lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb, line 61
def app_list_var
  'ALLOWED_APPS'
end
app_name() click to toggle source
# File lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb, line 73
def app_name
  context.heroku.app[env]
end
client() click to toggle source
# File lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb, line 77
def client
  context.heroku.api_client
end
current_config() click to toggle source
# File lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb, line 55
def current_config
  client.config_var.info_for_app(BRIDGE_APP)
rescue Excon::Error::Forbidden
  fail! "You are missing 'deploy' permissions for #{bold BRIDGE_APP}"
end
fix() click to toggle source
# File lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb, line 42
def fix
  app_list = Set.new current_config.fetch(app_list_var, '').split(',')
  app_list << app_name
  client.config_var.update(
    BRIDGE_APP,
    tags_var     => "app:#{app_name}",
    token_var    => SecureRandom.hex(16),
    app_list_var => app_list.to_a.join(',')
  )
rescue Excon::Error::Forbidden
  fail! "You are missing 'operate' permissions for #{bold BRIDGE_APP}"
end
tags_var() click to toggle source
# File lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb, line 65
def tags_var
  '%s_TAGS' % app_name.upcase
end
token_var() click to toggle source
# File lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb, line 69
def token_var
  '%s_PASSWORD' % app_name.upcase
end