Skip to content

Commit

Permalink
add new relic; add logs for translate post route; downgrade ruby to s…
Browse files Browse the repository at this point in the history
…upport new relic agent
  • Loading branch information
rshewitt committed Nov 26, 2024
1 parent 92b9591 commit 79e9e41
Show file tree
Hide file tree
Showing 10 changed files with 1,126 additions and 10 deletions.
9 changes: 9 additions & 0 deletions .profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -o errexit
set -o pipefail

# New Relic
service_name="datagov-harvest-secrets"
path=".credentials.NEW_RELIC_LICENSE_KEY"
export NEW_RELIC_LICENSE_KEY=$(echo $VCAP_SERVICES | jq --raw-output --arg service_name "$service_name" ".[][] | select(.name == \$service_name) | $path")
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.4
3.2.5
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.3.4
FROM ruby:3.2.5

RUN apt-get update -q

Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.3.4'
ruby '3.2.5'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.0.6', '>= 6.0.6.1'
Expand All @@ -18,6 +18,8 @@ gem 'puma', '~> 4.1'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

gem 'newrelic_rpm', '~> 9.16'

# downgrade psych in response to https://stackoverflow.com/questions/68802089/rails-couldnt-infer-whether-you-are-using-multiple-databases-from-your-database
gem 'psych', '< 4.0.0'

Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
newrelic_rpm (9.16.0)
nio4r (2.7.4)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
Expand Down Expand Up @@ -268,6 +269,7 @@ DEPENDENCIES
bootsnap (>= 1.4.2)
byebug
listen (~> 3.2)
newrelic_rpm (~> 9.16)
psych (< 4.0.0)
puma (~> 4.1)
rails (~> 6.0.6, >= 6.0.6.1)
Expand All @@ -279,7 +281,7 @@ DEPENDENCIES
tzinfo-data

RUBY VERSION
ruby 3.3.4p94
ruby 3.2.5p208

BUNDLED WITH
2.5.18
16 changes: 16 additions & 0 deletions app/controllers/translates_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'logger'

class TranslatesController < ApplicationController
# POST /translates
def create
Expand All @@ -14,6 +16,20 @@ def create
writer: writer_name
)

logger = Logger.new($stdout)

@md_return[:readerStructureMessages].each do |m|
logger.warn(m) if m.include? 'WARNING'
logger.info(m) if m.include? 'INFO'
logger.error(m) if m.include? 'ERROR'
end

@md_return[:readerValidationMessages].each do |m|
logger.warn(m) if m.include? 'WARNING'
logger.info(m) if m.include? 'INFO'
logger.error(m) if m.include? 'ERROR'
end

@response_info = {}
@response_info[:success] = true
@response_info[:readerStructureStatus] = 'OK'
Expand Down
4 changes: 4 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true

require 'newrelic_rpm'

Rails.application.configure do
config.log_formatter = ::NewRelic::Agent::Logging::DecoratingFormatter.new

# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
Expand Down
Loading

0 comments on commit 79e9e41

Please sign in to comment.