Skip to content

Commit

Permalink
Merge pull request #686 from trade-tariff/HOTT-3958-remove-nr
Browse files Browse the repository at this point in the history
HOTT-3958: Remove New Relic
  • Loading branch information
willfish committed Sep 7, 2023
2 parents daab763 + bae01f9 commit 2973aaa
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 37 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Expand Up @@ -7,7 +7,6 @@ repos:
- id: terraform_fmt
- id: terraform_validate
- id: terraform_tflint
- id: terraform_tfsec
- id: terraform_docs
args:
- --hook-config=--add-to-existing-file=true
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -13,7 +13,6 @@ gem 'govspeak'
gem 'govuk_design_system_formbuilder'
gem 'lograge'
gem 'logstash-event'
gem 'newrelic_rpm'
gem 'puma'
gem 'railties', '~> 7'
gem 'sentry-rails'
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Expand Up @@ -219,7 +219,6 @@ GEM
timeout
net-smtp (0.3.3)
net-protocol
newrelic_rpm (9.4.2)
nio4r (2.5.9)
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
Expand Down Expand Up @@ -610,7 +609,6 @@ DEPENDENCIES
lograge
logstash-event
multipart-post (= 2.3.0)
newrelic_rpm
pry-byebug
pry-rails
puma
Expand Down
11 changes: 0 additions & 11 deletions app/controllers/steps/base_controller.rb
Expand Up @@ -7,7 +7,6 @@ class BaseController < ::ApplicationController
rescue_from StandardError, with: :handle_exception

default_form_builder GOVUKDesignSystemFormBuilder::FormBuilder
after_action :track_session
before_action :ensure_session_integrity
before_action :initialize_commodity_context_service

Expand Down Expand Up @@ -44,15 +43,6 @@ def commodity_source
params[:referred_service] || user_session.commodity_source
end

def track_session
::NewRelic::Agent.add_custom_attributes({
session: user_session.session.to_h.except('_csrf_token'),
commodity_code: user_session.commodity_code,
commodity_source: user_session.commodity_source,
referred_service: user_session.referred_service,
})
end

def handle_exception(exception)
with_session_tracking do
raise exception
Expand Down Expand Up @@ -80,7 +70,6 @@ def title

def with_session_tracking
Sentry.set_user(user_session.session.to_h.except('_csrf_token'))
track_session
yield
end
end
Expand Down
12 changes: 0 additions & 12 deletions spec/controllers/steps/base_controller_spec.rb
Expand Up @@ -24,19 +24,13 @@ def create
end

before do
allow(NewRelic::Agent).to receive(:add_custom_attributes).and_call_original
allow(Sentry).to receive(:set_user)
allow(Rails.configuration).to receive(:trade_tariff_frontend_url).and_return(trade_tariff_host)
end

describe 'GET #index' do
subject(:response) { get :index }

it 'sends custom attributes to NewRelic' do
response
expect(NewRelic::Agent).to have_received(:add_custom_attributes).with(expected_tracked_attributes)
end

it 'initializes the CommodityContextService' do
response
expect(Thread.current[:commodity_context_service]).to be_a(CommodityContextService)
Expand All @@ -63,12 +57,6 @@ def create
rescue ArgumentError
expect(Sentry).to have_received(:set_user).with(user_session.session.to_h.except('_csrf_token'))
end

it 'sends custom attributes to NewRelic' do
response
rescue ArgumentError
expect(NewRelic::Agent).to have_received(:add_custom_attributes).with(expected_tracked_attributes)
end
end

describe '#title' do
Expand Down
1 change: 0 additions & 1 deletion terraform/README.md
Expand Up @@ -30,7 +30,6 @@ Terraform to deploy the service into AWS.
| [aws_kms_key.secretsmanager_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/kms_key) | data source |
| [aws_lb_target_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lb_target_group) | data source |
| [aws_secretsmanager_secret.duty_calculator_secret_key_base](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/secretsmanager_secret) | data source |
| [aws_secretsmanager_secret.newrelic_license_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/secretsmanager_secret) | data source |
| [aws_security_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/security_group) | data source |
| [aws_ssm_parameter.ecr_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
| [aws_subnets.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnets) | data source |
Expand Down
4 changes: 0 additions & 4 deletions terraform/data.tf
Expand Up @@ -25,10 +25,6 @@ data "aws_secretsmanager_secret" "duty_calculator_secret_key_base" {
name = "duty-calculator-secret-key-base"
}

data "aws_secretsmanager_secret" "newrelic_license_key" {
name = "newrelic-license-key"
}

data "aws_kms_key" "secretsmanager_key" {
key_id = "alias/secretsmanager-key"
}
Expand Down
1 change: 0 additions & 1 deletion terraform/iam.tf
Expand Up @@ -9,7 +9,6 @@ data "aws_iam_policy_document" "secrets" {
]
resources = [
data.aws_secretsmanager_secret.duty_calculator_secret_key_base.arn,
data.aws_secretsmanager_secret.newrelic_license_key.arn
]
}

Expand Down
4 changes: 0 additions & 4 deletions terraform/main.tf
Expand Up @@ -80,9 +80,5 @@ module "service" {
name = "SECRET_KEY_BASE"
valueFrom = data.aws_secretsmanager_secret.duty_calculator_secret_key_base.arn
},
{
name = "NEWRELIC_LICENSE_KEY"
valueFrom = data.aws_secretsmanager_secret.newrelic_license_key.arn
}
]
}

0 comments on commit 2973aaa

Please sign in to comment.