– Report each environment as separate app
– Report namespace so we can track down where misbehaving pods live
# config/application.rb (not in initializers)
if ENV['POD_NAMESPACE'] # on kubernetes
# report each env into a separate project
NewRelic::Agent::Configuration::Manager.class_eval do
undef app_names
def app_names
name = ENV.fetch('NEW_RELIC_APP_NAME')
name += " #{Rails.env}" unless Rails.env.production?
[name]
end
end
# report namespace so we can track down where a troublesome pod lives
# newrelic_rpm 3.18.0+ has a NEW_RELIC_PROCESS_HOST_DISPLAY_NAME setting which is supposed to do that, but did not work.
class << NewRelic::Agent::Hostname
def get
"#{ENV.fetch('POD_NAME')}.#{ENV.fetch('POD_NAMESPACE')}"
end
end
end