Skip to content

Commit

Permalink
Merge pull request #5 from GSA/integrate-newrelic
Browse files Browse the repository at this point in the history
integrate new relic
  • Loading branch information
rshewitt authored Jan 2, 2025
2 parents 92b9591 + 411af35 commit 0970f6e
Show file tree
Hide file tree
Showing 10 changed files with 1,137 additions and 16 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
33 changes: 27 additions & 6 deletions app/controllers/translates_controller.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
# frozen_string_literal: true

require 'logger'

class TranslatesController < ApplicationController
# POST /translates
def create
file_obj = params[:file]
reader_name = params[:reader]
writer_name = params[:writer]

@md_return =
ADIWG::Mdtranslator.translate(
file: file_obj,
reader: reader_name,
writer: writer_name
)
logger = Logger.new($stdout)

begin
@md_return =
ADIWG::Mdtranslator.translate(
file: file_obj,
reader: reader_name,
writer: writer_name
)
rescue StandardError => e
logger.error(e.message)
render json: {}, status: :internal_server_error
end

@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
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 0970f6e

Please sign in to comment.