Skip to content

Commit

Permalink
MAM-3095-load-test-20k-data-capture (#204)
Browse files Browse the repository at this point in the history
Full log replacement of Datadog with AppSignal.
Better Logging, Alerting, Simpler adding errors
  • Loading branch information
jtomchak authored Nov 8, 2023
1 parent 0e85014 commit 3ad025b
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 39 deletions.
2 changes: 2 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

require 'appsignal/capistrano'
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ end

group :production, :staging do
gem 'lograge', '~> 0.12'
gem 'ddtrace', require: 'ddtrace/auto_instrument'
gem 'google-protobuf', '~> 3.0'
end

Expand All @@ -213,3 +212,6 @@ gem 'bcrypt_pbkdf', '>= 1.0', '< 2.0'

# Use Json Web Token (JWT) for token based authentication Mammoth
gem 'jwt'

# Appsignal
gem 'appsignal'
16 changes: 3 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ GEM
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
appsignal (3.4.14)
rack
ast (2.4.2)
async (1.31.0)
console (~> 1.10)
Expand Down Expand Up @@ -245,16 +247,7 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
datadog-ci (0.2.0)
msgpack
date (3.3.3)
ddtrace (1.15.0)
datadog-ci (~> 0.2.0)
debase-ruby_core_source (= 3.2.2)
libdatadog (~> 5.0.0.1.0)
libddwaf (~> 1.14.0.0.0)
msgpack
debase-ruby_core_source (3.2.2)
debug_inspector (1.1.0)
devise (4.9.2)
bcrypt (~> 3.0)
Expand Down Expand Up @@ -457,9 +450,6 @@ GEM
letter_opener (~> 1.7)
railties (>= 5.2)
rexml
libdatadog (5.0.0.1.0)
libddwaf (1.14.0.0.0)
ffi (~> 1.0)
link_header (0.0.8)
llhttp-ffi (0.4.0)
ffi-compiler (~> 1.0)
Expand Down Expand Up @@ -865,6 +855,7 @@ DEPENDENCIES
active_model_serializers (~> 0.10)
addressable (~> 2.8)
annotate (~> 3.2)
appsignal
async (~> 1.31)
async-http
aws-sdk-s3 (~> 1.123)
Expand All @@ -889,7 +880,6 @@ DEPENDENCIES
concurrent-ruby
connection_pool
database_cleaner-active_record
ddtrace
devise (~> 4.9)
devise-two-factor (~> 4.1)
devise_pam_authenticatable2 (~> 9.2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def perform
def update_channel_feeds!
@channels = Mammoth::Channels.new.channels_with_statuses
@channels.each do |channel|
Rails.logger.info { "CHANNEL:: #{channel} \n" }
Rails.logger.debug { "CHANNEL:: #{channel} \n" }
push_statuses(channel[:statuses], channel[:id])
end
end
Expand Down
8 changes: 6 additions & 2 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require File.expand_path('config/environment', __dir__)
begin
require File.expand_path('config/environment', __dir__)
rescue Exception => e
Appsignal.send_error(e)
raise
end
run Rails.application
1 change: 0 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#require 'action_mailbox/engine'
#require 'action_text/engine'
#require 'rails/test_unit/railtie'
require 'datadog/profiling/preload'
require 'sprockets/railtie'

# Used to be implicitly required in action_mailbox/engine
Expand Down
47 changes: 47 additions & 0 deletions config/appsignal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
default:
&defaults # Your push api key, it is possible to set this dynamically using ERB:
push_api_key: "<%= ENV['APPSIGNAL_PUSH_API_KEY'] %>"

# Your app's name
name: 'moth.social'
working_directory_path: '/tmp/appsignal'

# Actions that should not be monitored by AppSignal
# ignore_actions:
# - ApplicationController#isup

# Errors that should not be recorded by AppSignal
# For more information see our docs:
# https://docs.appsignal.com/ruby/configuration/ignore-errors.html
# ignore_errors:
# - Exception
# - NoMemoryError
# - ScriptError
# - LoadError
# - NotImplementedError
# - SyntaxError
# - SecurityError
# - SignalException
# - Interrupt
# - SystemExit
# - SystemStackError

# See https://docs.appsignal.com/ruby/configuration/options.html for
# all configuration options.

# Configuration per environment, leave out an environment or set active
# to false to not push metrics for that environment.

development:
<<: *defaults
active: true

production:
<<: *defaults
active: true
enable_nginx_metrics: true

staging:
<<: *defaults
active: true
enable_nginx_metrics: true
1 change: 1 addition & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
set :rbenv_type, :user
set :rbenv_ruby, File.read('.ruby-version').strip
set :migration_role, :app
set :appsignal_config, name: 'moth.social'

append :linked_dirs, 'vendor/bundle', 'public/system'

Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# information to avoid inadvertent exposure of personally identifiable information (PII).
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'warn').to_sym
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info').to_sym

# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
Expand Down
20 changes: 0 additions & 20 deletions config/initializers/datadog-tracer.rb

This file was deleted.

6 changes: 6 additions & 0 deletions config/initializers/logging.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true


console_logger = ActiveSupport::Logger.new(STDOUT)
appsignal_logger = ActiveSupport::TaggedLogging.new(Appsignal::Logger.new('rails'))
Rails.logger = console_logger.extend(ActiveSupport::Logger.broadcast(appsignal_logger))

0 comments on commit 3ad025b

Please sign in to comment.