Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
Add new relic (#632)
Browse files Browse the repository at this point in the history
* add new relic

* run rubocop
  • Loading branch information
FinnIckler authored Jul 30, 2024
1 parent 0cf3287 commit 83f8b73
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ group :development do
gem 'better_errors'
gem 'binding_of_caller'
end

group :production do
gem 'newrelic_rpm'
end
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
newrelic_rpm (9.12.0)
nio4r (2.7.3)
nokogiri (1.16.6-aarch64-linux)
racc (~> 1.4)
Expand Down Expand Up @@ -373,6 +374,7 @@ DEPENDENCIES
jwt
kredis
money-rails
newrelic_rpm
overcommit
prometheus_exporter
pry
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
class ApplicationController < ActionController::API
prepend_before_action :validate_jwt_token
around_action :performance_profile if Rails.env.development?

# Manually include new Relic because we don't derive from ActionController::Base
include NewRelic::Agent::Instrumentation::ControllerInstrumentation if Rails.env.production?

def validate_jwt_token
auth_header = request.headers['Authorization']
if auth_header.blank?
Expand Down
1 change: 1 addition & 0 deletions app_secrets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def vault(secret_name, &block)

vault :JWT_SECRET
vault :SECRET_KEY_BASE
vault :NEW_RELIC_LICENSE_KEY

else
mandatory :JWT_SECRET, :string
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Application < Rails::Application

config.autoload_paths += Dir["#{config.root}/lib"]
config.active_job.queue_adapter = :shoryuken
config.site_name = 'WCA Registration Service'

# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
Expand Down
58 changes: 58 additions & 0 deletions config/newrelic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# This file configures the New Relic Agent. New Relic monitors Ruby, Java,
# .NET, PHP, Python and Node applications with deep visibility and low
# overhead. For more information, visit www.newrelic.com.
#
# Generated August 19, 2015
#
# This configuration file is custom generated for World Cube Association_1
#
# 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: <%= AppSecrets.NEW_RELIC_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: <%= WcaRegistration::Application.config.site_name %> <%= EnvConfig.REGISTRATION_LIVE_SITE? ? "production" : "staging" %>

# To disable the agent regardless of other settings, uncomment the following:
# agent_enabled: false

# Logging level for log/newrelic_agent.log
log_level: info

# Error collector captures information about uncaught exceptions and
# sends them to RPM for viewing
error_collector:

# Error collector is enabled by default. Set this to false to turn
# it off. This feature is only available at the Silver and above
# product levels
enabled: true

# Tells error collector whether or not to capture a source snippet
# around the place of the error when errors are View related.
capture_source: true

# To stop specific errors from reporting to RPM, set this property
# to comma separated values.
ignore_errors: "ActionController::RoutingError, ActiveRecord::RecordNotFound"


# 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
monitor_mode: false

test:
<<: *default_settings
# It doesn't make sense to report to New Relic from automated test runs.
monitor_mode: false

production:
<<: *default_settings

0 comments on commit 83f8b73

Please sign in to comment.