From f7493e717c4a5cbc34d8cc60d21ab00ce24d78b2 Mon Sep 17 00:00:00 2001 From: Brian Kelly Date: Tue, 23 Jul 2024 11:50:48 -0500 Subject: [PATCH 1/2] Set up New Relic for Staging and Production (#334) --- Gemfile | 1 + Gemfile.lock | 2 + config/deploy/production.rb | 4 +- config/deploy/staging.rb | 4 +- config/newrelic.yml | 68 +++++++++++++++++++++++++++++++++ config/settings/development.yml | 1 + config/settings/test.yml | 1 + 7 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 config/newrelic.yml diff --git a/Gemfile b/Gemfile index 9dc3bbe4..bf99e93f 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ gem 'importmap-rails' gem 'jbuilder' gem 'jquery-rails' gem 'mysql2' +gem 'newrelic_rpm' gem 'omniauth', '1.9.2' gem 'omniauth-oauth2' gem 'omniauth-rails_csrf_protection' diff --git a/Gemfile.lock b/Gemfile.lock index 52944dd5..fd13cca1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -341,6 +341,7 @@ GEM net-smtp (0.5.0) net-protocol net-ssh (7.2.0) + newrelic_rpm (9.11.0) nio4r (2.7.3) nokogiri (1.16.6-arm64-darwin) racc (~> 1.4) @@ -591,6 +592,7 @@ DEPENDENCIES jbuilder jquery-rails mysql2 + newrelic_rpm omniauth (= 1.9.2) omniauth-oauth2 omniauth-rails_csrf_protection diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 5ab191d8..27c2d581 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -31,7 +31,9 @@ # http://capistranorb.com/documentation/getting-started/configuration/ # Feel free to add new variables to customise your setup. - +set :default_env, { + 'NEW_RELIC_ENV' => 'production' +} # Custom SSH Options # ================== diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index dc6cc413..1018f8dc 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -31,7 +31,9 @@ # http://capistranorb.com/documentation/getting-started/configuration/ # Feel free to add new variables to customise your setup. - +set :default_env, { + 'NEW_RELIC_ENV' => 'staging' +} # Custom SSH Options # ================== diff --git a/config/newrelic.yml b/config/newrelic.yml new file mode 100644 index 00000000..3d60e655 --- /dev/null +++ b/config/newrelic.yml @@ -0,0 +1,68 @@ +# +# This file configures the New Relic Agent. New Relic monitors Ruby, Java, +# .NET, PHP, Python, Node, and Go applications with deep visibility and low +# overhead. For more information, visit www.newrelic.com. +# +# Generated October 28, 2022 +# +# This configuration file is custom generated for NewRelic Administration +# +# For full documentation of agent configuration options, please refer to +# https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration + +common: &default_settings + # Required license key associated with your New Relic account. + license_key: <%= Settings.NEWRELIC_LICENSE_KEY %> + + # Your application name. Renaming here affects where data displays in New + # Relic. For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications + app_name: 'Spatial Data Repository' + + distributed_tracing: + enabled: true + + # To disable the agent regardless of other settings, uncomment the following: + + # agent_enabled: false + + # Logging level for log/newrelic_agent.log + log_level: info + + application_logging: + # If `true`, all logging-related features for the agent can be enabled or disabled + # independently. If `false`, all logging-related features are disabled. + enabled: true + forwarding: + # If `true`, the agent captures log records emitted by this application. + enabled: true + # Defines the maximum number of log records to buffer in memory at a time. + max_samples_stored: 10000 + metrics: + # If `true`, the agent captures metrics related to logging for this application. + enabled: true + local_decorating: + # If `true`, the agent decorates logs with metadata to link to entities, hosts, traces, and spans. + # This requires a log forwarder to send your log files to New Relic. + # This should not be used when forwarding is enabled. + enabled: false + +# Environment-specific settings are in this section. +# RAILS_ENV or RACK_ENV (as appropriate) is used to determine the environment. +# If your application has other named environments, configure them here. +development: + <<: *default_settings + app_name: 'Spatial Data Repository (Development)' + # Disabled to avoid checking in New Relic license key into Git for now + monitor_mode: false + +test: + <<: *default_settings + # It doesn't make sense to report to New Relic from automated test runs. + monitor_mode: false + +staging: + <<: *default_settings + app_name: 'Spatial Data Repository (Staging)' + +production: + <<: *default_settings diff --git a/config/settings/development.yml b/config/settings/development.yml index 2d496aa3..dbd3773f 100644 --- a/config/settings/development.yml +++ b/config/settings/development.yml @@ -1,6 +1,7 @@ SECRET_KEY_BASE: 6c51f19b57fdebd3dfd2a3cf8b69fab7f41a529b6bfbf8bff4a85815934066cbe22ddf7fa6083f227288c04e4eeb6c28f0fd90e31fc02314aaceb135dacecc07 DEVISE_SECRET_TOKEN: 2c847492b6d434c808e63a93ff16a7a897aa4c09943edaaf7aa498a29649048113cf55731282e39a82ae7ce3fb9f1087586d474fc483ad6f63806986a5a02a6c +NEWRELIC_LICENSE_KEY: none SOLR_INSTANCE_DIR: tmp/sdr-core-development SOLR_INSTANCE_NAME: sdr-core-development SOLR_URL: http://127.0.0.1:8989/solr/sdr-core-development diff --git a/config/settings/test.yml b/config/settings/test.yml index 84703f58..30a6919e 100644 --- a/config/settings/test.yml +++ b/config/settings/test.yml @@ -1,6 +1,7 @@ SECRET_KEY_BASE: 6c51f19b57fdebd3dfd2a3cf8b69fab7f41a529b6bfbf8bff4a85815934066cbe22ddf7fa6083f227288c04e4eeb6c28f0fd90e31fc02314aaceb135dacecc07 DEVISE_SECRET_TOKEN: bfbd360e6b465662c331578b3598323559980c73fde2dea24a8253089a5efa8f27775e9ba60838128e9f3feaec643c67397d8bd5f7c6f67a4b06114b32cc617c +NEWRELIC_LICENSE_KEY: none SOLR_INSTANCE_DIR: tmp/sdr-core-test SOLR_INSTANCE_NAME: sdr-core-test SOLR_URL: http://127.0.0.1:8983/solr/sdr-core-test From 059479164607e789a7573ab02b55f874bf28159c Mon Sep 17 00:00:00 2001 From: Brian Kelly Date: Tue, 23 Jul 2024 15:29:44 -0500 Subject: [PATCH 2/2] Remove Capistrano configuration that had no actual effect (#335) --- config/deploy/production.rb | 4 +--- config/deploy/staging.rb | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 27c2d581..5ab191d8 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -31,9 +31,7 @@ # http://capistranorb.com/documentation/getting-started/configuration/ # Feel free to add new variables to customise your setup. -set :default_env, { - 'NEW_RELIC_ENV' => 'production' -} + # Custom SSH Options # ================== diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index 1018f8dc..dc6cc413 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -31,9 +31,7 @@ # http://capistranorb.com/documentation/getting-started/configuration/ # Feel free to add new variables to customise your setup. -set :default_env, { - 'NEW_RELIC_ENV' => 'staging' -} + # Custom SSH Options # ==================