Merge branch 'hotfix/3.3.7' into develop
This commit is contained in:
@@ -9,3 +9,6 @@ APP_HOST=http://localhost:3000
|
|||||||
EXTENSIONS_MANAGER_LOCATION=extensions/extensions-manager/dist/index.html
|
EXTENSIONS_MANAGER_LOCATION=extensions/extensions-manager/dist/index.html
|
||||||
BATCH_MANAGER_LOCATION=extensions/batch-manager/dist/index.min.html
|
BATCH_MANAGER_LOCATION=extensions/batch-manager/dist/index.min.html
|
||||||
SF_DEFAULT_SERVER=http://localhost:3001
|
SF_DEFAULT_SERVER=http://localhost:3001
|
||||||
|
|
||||||
|
# Datadog
|
||||||
|
DATADOG_ENABLED=false
|
||||||
|
|||||||
5
Gemfile
5
Gemfile
@@ -46,3 +46,8 @@ group :development, :test do
|
|||||||
gem 'capistrano-sidekiq'
|
gem 'capistrano-sidekiq'
|
||||||
gem 'capistrano-git-with-submodules', '~> 2.0'
|
gem 'capistrano-git-with-submodules', '~> 2.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
gem "dogstatsd-ruby", "~> 4.8"
|
||||||
|
gem "ddtrace", "~> 0.38.0"
|
||||||
|
|
||||||
|
gem "lograge", "~> 0.11.2"
|
||||||
|
|||||||
15
Gemfile.lock
15
Gemfile.lock
@@ -67,6 +67,9 @@ GEM
|
|||||||
concurrent-ruby (1.1.5)
|
concurrent-ruby (1.1.5)
|
||||||
connection_pool (2.2.2)
|
connection_pool (2.2.2)
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
|
ddtrace (0.38.0)
|
||||||
|
msgpack
|
||||||
|
dogstatsd-ruby (4.8.1)
|
||||||
dotenv (2.7.5)
|
dotenv (2.7.5)
|
||||||
dotenv-rails (2.7.5)
|
dotenv-rails (2.7.5)
|
||||||
dotenv (= 2.7.5)
|
dotenv (= 2.7.5)
|
||||||
@@ -83,6 +86,11 @@ GEM
|
|||||||
i18n (1.8.2)
|
i18n (1.8.2)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
json (1.8.6)
|
json (1.8.6)
|
||||||
|
lograge (0.11.2)
|
||||||
|
actionpack (>= 4)
|
||||||
|
activesupport (>= 4)
|
||||||
|
railties (>= 4)
|
||||||
|
request_store (~> 1.0)
|
||||||
loofah (2.4.0)
|
loofah (2.4.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
@@ -92,6 +100,8 @@ GEM
|
|||||||
mini_mime (1.0.2)
|
mini_mime (1.0.2)
|
||||||
mini_portile2 (2.4.0)
|
mini_portile2 (2.4.0)
|
||||||
minitest (5.14.0)
|
minitest (5.14.0)
|
||||||
|
msgpack (1.3.3)
|
||||||
|
msgpack (1.3.3-x64-mingw32)
|
||||||
net-scp (2.0.0)
|
net-scp (2.0.0)
|
||||||
net-ssh (>= 2.6.5, < 6.0.0)
|
net-ssh (>= 2.6.5, < 6.0.0)
|
||||||
net-ssh (5.2.0)
|
net-ssh (5.2.0)
|
||||||
@@ -140,6 +150,8 @@ GEM
|
|||||||
ffi (~> 1.0)
|
ffi (~> 1.0)
|
||||||
rdoc (4.3.0)
|
rdoc (4.3.0)
|
||||||
redis (4.1.3)
|
redis (4.1.3)
|
||||||
|
request_store (1.5.0)
|
||||||
|
rack (>= 1.4)
|
||||||
responders (2.4.1)
|
responders (2.4.1)
|
||||||
actionpack (>= 4.2.0, < 6.0)
|
actionpack (>= 4.2.0, < 6.0)
|
||||||
railties (>= 4.2.0, < 6.0)
|
railties (>= 4.2.0, < 6.0)
|
||||||
@@ -200,8 +212,11 @@ DEPENDENCIES
|
|||||||
capistrano-rails
|
capistrano-rails
|
||||||
capistrano-rvm
|
capistrano-rvm
|
||||||
capistrano-sidekiq
|
capistrano-sidekiq
|
||||||
|
ddtrace (~> 0.38.0)
|
||||||
|
dogstatsd-ruby (~> 4.8)
|
||||||
dotenv-rails
|
dotenv-rails
|
||||||
haml
|
haml
|
||||||
|
lograge (~> 0.11.2)
|
||||||
non-stupid-digest-assets
|
non-stupid-digest-assets
|
||||||
puma
|
puma
|
||||||
rack-cors
|
rack-cors
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ class ApplicationController < ActionController::Base
|
|||||||
rescue_from ActionView::MissingTemplate do |exception|
|
rescue_from ActionView::MissingTemplate do |exception|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def route_not_found
|
||||||
|
render :json => {:error => {:message => "Not found."}}, :status => 404
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def allow_iframe
|
def allow_iframe
|
||||||
@@ -24,4 +28,19 @@ class ApplicationController < ActionController::Base
|
|||||||
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
|
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def append_info_to_payload(payload)
|
||||||
|
super
|
||||||
|
|
||||||
|
unless payload[:status]
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
payload[:level] = 'INFO'
|
||||||
|
if payload[:status] >= 500
|
||||||
|
payload[:level] = 'ERROR'
|
||||||
|
elsif payload[:status] >= 400
|
||||||
|
payload[:level] = 'WARN'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,8 +14,12 @@ Rails.application.configure do
|
|||||||
# Do not eager load code on boot.
|
# Do not eager load code on boot.
|
||||||
config.eager_load = false
|
config.eager_load = false
|
||||||
|
|
||||||
require 'custom_log_formatter'
|
MAX_LOG_MEGABYTES = 50
|
||||||
config.log_formatter = CustomLogFormatter.new
|
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
|
||||||
|
|
||||||
|
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
||||||
|
config.logger = ActiveSupport::Logger.new(STDOUT)
|
||||||
|
end
|
||||||
|
|
||||||
# Show full error reports and disable caching.
|
# Show full error reports and disable caching.
|
||||||
config.consider_all_requests_local = true
|
config.consider_all_requests_local = true
|
||||||
|
|||||||
@@ -7,21 +7,13 @@ Rails.application.configure do
|
|||||||
# Code is not reloaded between requests.
|
# Code is not reloaded between requests.
|
||||||
config.cache_classes = true
|
config.cache_classes = true
|
||||||
|
|
||||||
# Use a different logger for distributed setups.
|
MAX_LOG_MEGABYTES = 50
|
||||||
# require 'syslog/logger'
|
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
|
||||||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
|
||||||
|
|
||||||
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
||||||
config.logger = ActiveSupport::Logger.new(STDOUT)
|
config.logger = ActiveSupport::Logger.new(STDOUT)
|
||||||
else
|
|
||||||
MAX_LOG_MEGABYTES = 50
|
|
||||||
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'custom_log_formatter'
|
|
||||||
config.log_formatter = CustomLogFormatter.new
|
|
||||||
config.logger.formatter = config.log_formatter
|
|
||||||
|
|
||||||
# Eager load code on boot. This eager loads most of Rails and
|
# Eager load code on boot. This eager loads most of Rails and
|
||||||
# your application in memory, allowing both threaded web servers
|
# your application in memory, allowing both threaded web servers
|
||||||
# and those relying on copy on write to perform better.
|
# and those relying on copy on write to perform better.
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ Rails.application.configure do
|
|||||||
# require 'syslog/logger'
|
# require 'syslog/logger'
|
||||||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
||||||
|
|
||||||
|
MAX_LOG_MEGABYTES = 50
|
||||||
|
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
|
||||||
|
|
||||||
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
||||||
logger = ActiveSupport::Logger.new(STDOUT)
|
config.logger = ActiveSupport::Logger.new(STDOUT)
|
||||||
logger.formatter = config.log_formatter
|
|
||||||
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Eager load code on boot. This eager loads most of Rails and
|
# Eager load code on boot. This eager loads most of Rails and
|
||||||
@@ -73,9 +74,6 @@ Rails.application.configure do
|
|||||||
# Send deprecation notices to registered listeners.
|
# Send deprecation notices to registered listeners.
|
||||||
config.active_support.deprecation = :notify
|
config.active_support.deprecation = :notify
|
||||||
|
|
||||||
# Use default logging formatter so that PID and timestamp are not suppressed.
|
|
||||||
config.log_formatter = ::Logger::Formatter.new
|
|
||||||
|
|
||||||
# Do not dump schema after migrations.
|
# Do not dump schema after migrations.
|
||||||
# config.active_record.dump_schema_after_migration = false
|
# config.active_record.dump_schema_after_migration = false
|
||||||
end
|
end
|
||||||
|
|||||||
6
config/initializers/datadog.rb
Normal file
6
config/initializers/datadog.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
if ENV['DATADOG_ENABLED'] == 'true'
|
||||||
|
Datadog.configure do |c|
|
||||||
|
# This will activate auto-instrumentation for Rails
|
||||||
|
c.use :rails
|
||||||
|
end
|
||||||
|
end
|
||||||
14
config/initializers/lograge.rb
Normal file
14
config/initializers/lograge.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
Rails.application.configure do
|
||||||
|
config.lograge.enabled = true
|
||||||
|
|
||||||
|
# Generate log in JSON
|
||||||
|
config.lograge.formatter = Lograge::Formatters::Json.new
|
||||||
|
config.lograge.custom_options = lambda do |event|
|
||||||
|
{
|
||||||
|
:ddsource => ["ruby"],
|
||||||
|
:time => event.time,
|
||||||
|
:params => event.payload[:params],
|
||||||
|
:level => event.payload[:level]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
get "/healthcheck" => "health_check#index"
|
get "/healthcheck" => "health_check#index"
|
||||||
|
|
||||||
|
get '*unmatched_route', to: 'application#route_not_found'
|
||||||
|
|
||||||
root 'application#app'
|
root 'application#app'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
class CustomLogFormatter < ActiveSupport::Logger::SimpleFormatter
|
|
||||||
SEVERITY_TO_COLOR_MAP = {'DEBUG'=>'0;37', 'INFO'=>'32', 'WARN'=>'33', 'ERROR'=>'31', 'FATAL'=>'31', 'UNKNOWN'=>'37'}
|
|
||||||
|
|
||||||
IPRegexp = /\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b/
|
|
||||||
FilteredString = '**FILTERED**'
|
|
||||||
|
|
||||||
def call(severity, time, progname, msg)
|
|
||||||
formatted_severity = sprintf("%-5s","#{severity}")
|
|
||||||
formatted_time = time.strftime("%Y-%m-%d %H:%M:%S.") << time.usec.to_s[0..2].rjust(3)
|
|
||||||
color = SEVERITY_TO_COLOR_MAP[severity]
|
|
||||||
|
|
||||||
"\033[0;37m#{formatted_time}\033[0m [\033[#{color}m#{formatted_severity}\033[0m] #{filter_ip(msg)} (pid:#{$$})\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
def filter_ip(msg)
|
|
||||||
if msg.is_a? String
|
|
||||||
return msg.gsub(IPRegexp, FilteredString).strip
|
|
||||||
else
|
|
||||||
return msg
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user