Skip to content

Commit

Permalink
Switch to AppSignal
Browse files Browse the repository at this point in the history
  • Loading branch information
miharekar committed Nov 10, 2023
1 parent 17cff54 commit c1554a5
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 47 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ gem "turbo-rails"
gem "pghero"
gem "pg_query"
gem "rack-mini-profiler"
gem "rorvswild"
gem "stackprof"

group :production do
gem "appsignal"
end

group :development, :test do
gem "debug"
end
Expand Down
22 changes: 11 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ GEM
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
appsignal (3.4.14)
rack
ast (2.4.2)
aws-eventstream (1.2.0)
aws-partitions (1.846.0)
aws-partitions (1.848.0)
aws-sdk-core (3.186.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
Expand All @@ -114,7 +116,7 @@ GEM
aws-sigv4 (1.6.1)
aws-eventstream (~> 1, >= 1.0.2)
aws_cf_signer (0.1.3)
base64 (0.1.1)
base64 (0.2.0)
bcrypt (3.1.19)
benchmark-ips (2.12.0)
bigdecimal (3.1.4)
Expand Down Expand Up @@ -355,7 +357,7 @@ GEM
redis-client (0.18.0)
connection_pool
regexp_parser (2.8.2)
reline (0.3.9)
reline (0.4.0)
io-console (~> 0.5)
responders (3.1.1)
actionpack (>= 5.2)
Expand All @@ -366,13 +368,11 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.6)
rorvswild (1.6.2)
rubocop (1.56.4)
base64 (~> 0.1.1)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
Expand Down Expand Up @@ -411,10 +411,10 @@ GEM
hashie
version_gem (~> 1.1, >= 1.1.1)
stackprof (0.2.25)
standard (1.31.2)
standard (1.32.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.56.4)
rubocop (~> 1.57.2)
standard-custom (~> 1.0.0)
standard-performance (~> 1.2)
standard-custom (1.0.2)
Expand All @@ -428,7 +428,7 @@ GEM
rubocop-rails (~> 2.20.2)
stimulus-rails (1.3.0)
railties (>= 6.0.0)
stringio (3.0.8)
stringio (3.0.9)
stripe (10.1.0)
tailwindcss-rails (2.0.32-aarch64-linux)
railties (>= 6.0.0)
Expand Down Expand Up @@ -479,6 +479,7 @@ PLATFORMS
DEPENDENCIES
active_link_to
annotate
appsignal
aws-sdk-s3
benchmark-ips
bootsnap
Expand Down Expand Up @@ -509,7 +510,6 @@ DEPENDENCIES
rails
redis
responders
rorvswild
rubocop
rubocop-performance
rubocop-rails
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/airtable_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def notification
AirtableWebhookJob.set(wait: 1.minute).perform_later(airtable_info)
end
else
RorVsWild.send_message("Airtable webhook received for unknown webhook id: #{params["webhook"]["id"]}", params:)
Rails.logger.warn("Airtable webhook received for unknown webhook id: #{params["webhook"]["id"]}", {params:})
end
head :ok
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
before_action :profiling
before_action :set_timezone
before_action :set_skin
before_action :set_context
before_action :tag_request

private

Expand All @@ -26,8 +26,8 @@ def set_skin
@skin = [@skin, cookies["browser.colorscheme"].presence].compact.join(" ") if @skin == "system"
end

def set_context
RorVsWild.merge_error_context(email: current_user&.email, user_id: current_user&.id)
def tag_request
Appsignal.tag_request(email: current_user&.email, user_id: current_user&.id)
end

def check_admin!
Expand Down
4 changes: 3 additions & 1 deletion app/jobs/airtable_shot_upload_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def perform(shot)
if json["error"]["type"] == "INVALID_PERMISSIONS_OR_MODEL_NOT_FOUND"
shot.user.identities.by_provider(:airtable).first.destroy
else
RorVsWild.record_error(e, shot_id: shot.id, user_id: shot.user_id)
Appsignal.send_error(e) do |transaction|
transaction.set_tags(shot_id: shot.id, user_id: shot.user_id)
end
end
end
end
4 changes: 3 additions & 1 deletion app/jobs/airtable_webhook_refresh_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def refresh_webhook(airtable_info)
if %w[NOT_FOUND INVALID_PERMISSIONS_OR_MODEL_NOT_FOUND CANNOT_REFRESH_DISABLED_WEBHOOK].include?(json["error"]["type"])
airtable_info.destroy
else
RorVsWild.record_error(e, user_id: user.id)
Appsignal.send_error(e) do |transaction|
transaction.set_tags(user_id: user.id)
end
end
end
end
2 changes: 1 addition & 1 deletion app/jobs/duplicate_stripe_subscriptions_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def perform(*args)
end
end
active_subscriptions.select { |email, subscriptions| subscriptions.count > 1 }.each do |email, subscriptions|
RorVsWild.send_message("Duplicate subscription for #{email}", email:, subscriptions:)
Rails.logger.warn("Duplicate subscription for #{email}", {mail:, subscriptions:})
end
end
end
4 changes: 3 additions & 1 deletion app/jobs/process_image_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class ProcessImageJob < ApplicationJob
def perform(blob, options)
blob.variant(options).processed
rescue Vips::Error => e
RorVsWild.record_error(e, blob_id: blob.id, attachments: blob.attachments.map { |a| a.record.to_global_id.to_s })
Appsignal.send_error(e) do |transaction|
transaction.set_tags(blob_id: blob.id, attachments: blob.attachments.map { |a| a.record.to_global_id.to_s })
end
blob.attachments.each { |a| a.purge_later }
end
end
4 changes: 3 additions & 1 deletion app/models/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def refresh_token!
Sidekiq.redis { |r| r.del(refresh_token_key) }
rescue OAuth2::Error => e
if Oj.load(e.body)["error"] == "invalid_grant"
RorVsWild.record_error(e, user_id:)
Appsignal.send_error(e) do |transaction|
transaction.set_tags(user_id:)
end
destroy!
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/parsers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def build_shot(user)
shot.errors.add(:base, :profile_file, message: "This is a profile file, not a shot file")
elsif Rails.env.production?
s3_response = Aws::S3::Client.new.put_object(acl: "private", body: file, bucket: "visualizer-coffee", key: "debug/#{Time.zone.now.iso8601}.json")
RorVsWild.send_message("Something is wrong with this file", etag: s3_response.etag, user_id: user.id, user_email: user.email)
Rails.logger.warn("Something is wrong with this file", {etag: s3_response.etag, user_id: user.id, user_email: user.email})
end
shot
end
Expand Down
40 changes: 40 additions & 0 deletions config/appsignal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
default: &defaults
# Your push api key, it is possible to set this dynamically using ERB:
# push_api_key: "<%= ENV['APPSIGNAL_PUSH_API_KEY'] %>"
push_api_key: "e4a2e7d0-4847-47c0-8f86-d042b8726e82"

# Your app's name
name: "Visualizer"

# 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: false

production:
<<: *defaults
active: true
2 changes: 1 addition & 1 deletion config/credentials/production.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
RmYd/eZtyrMdFIfgzT8OZ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eV3jfm9Bwxeia+t4i4VOf0MwFlY/RjteVzBC0zzbKSLob8Y2o/narpl/+FXaGAsu2I5BppRYjfj/eTBUSYybKuDZHQrya6Mhd1LIWrpAE4zFm4EBVVw3DqioelipCVvzdXwNduuIYFho10ZlfGzFQtN7tP0o7UQgcq1DjoXvsdU4yf6pU/rlyrGTmZNp9FchtcuKXwNPNvlBjfBvNbmYPY50KWyoM1NgZYh96AbmZwfFbLSb/3YTGOs0+3OSMdIAJ8hOjwkb7596eK6B4rgI4Mtvmdv9KwKgpp9ShLPc/8HfOZjEBXazrjGWq+tHPRkMvw41s0KhjVhfpAQ5Tz/lbepyX2tbVxZSVvOIwcXYsZTH1hOiN4w09djtAjFnEWyokQzHWjtDtDNe4DXGcHq5HPPrvUkH5al0OBrWnG7u+NT7H5OKA5e7wjxp8WXzE0KuxlcRHyEz+juqovLvGFe3S+kLBUfA5V815dBdkq/BMNAzn7Oz0YpcE/lLcj38He1L4f4NSZ4iR2GSHzUAHy3cf36wvdXxjha5oiyT0zx07K0FQ67lJ+YD82YWFWRek6mSNgMWDBLjJdrMl8xbSdd8JEJQAvF/PAMwA3eN9Oc3MjWzzWMOFZV9mrZs+17LCm4PlSK/D9Q0VX7U4pRXDyn7vwA0BVCQiyA2SxggTZhiiFhkM5alRHKKCN2UKCOSPer9kiYNrJXZaQz4MzoN5qt--rlU1I7CtvB7tm5jy--WajH6CHYsWwDZLM7W7/CqQ==
6 changes: 4 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true

# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new($stdout)
config.log_tags = [:request_id]
console_logger = ActiveSupport::Logger.new($stdout)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
appsignal_logger = ActiveSupport::TaggedLogging.new(Appsignal::Logger.new("rails"))
config.logger = ActiveSupport::BroadcastLogger.new(console_logger, appsignal_logger)

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

This file was deleted.

0 comments on commit c1554a5

Please sign in to comment.