chore: Load only required APMs (#6497)

- Disable requiring the gems for all the APMs 
- Switch to selectively requiring them.
This commit is contained in:
Sojan Jose
2023-03-01 14:31:51 +05:30
committed by GitHub
parent 4c921d3d0e
commit c9c3ac4b44
5 changed files with 38 additions and 10 deletions

View File

@@ -8,6 +8,20 @@ require 'rails/all'
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
## Load the specific APM agent
# We rely on DOTENV to load the environment variables
# We need these environment variables to load the specific APM agent
Dotenv::Railtie.load
require 'ddtrace' if ENV.fetch('DD_TRACE_AGENT_URL', false).present?
require 'elastic-apm' if ENV.fetch('ELASTIC_APM_SECRET_TOKEN', false).present?
require 'newrelic_rpm' if ENV.fetch('NEW_RELIC_LICENSE_KEY', false).present?
require 'scout_apm' if ENV.fetch('SCOUT_KEY', false).present?
if ENV.fetch('SENTRY_DSN', false).present?
require 'sentry-ruby'
require 'sentry-rails'
require 'sentry-sidekiq'
end
module Chatwoot
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.

10
config/scout_apm.yml Normal file
View File

@@ -0,0 +1,10 @@
common: &defaults
name: <%= ENV.fetch('SCOUT_NAME', '') %>
key: <%= ENV.fetch('SCOUT_KEY', '') %>
monitor: <%= ENV['SCOUT_KEY'].present? && ENV.fetch('SCOUT_MONITOR', true) %>
test:
monitor: <%= ENV['SCOUT_KEY'].present? && ENV.fetch('SCOUT_MONITOR', true) %>
production:
<<: *defaults