diff --git a/Gemfile b/Gemfile index 6a89a9ea4..ea6548a8b 100644 --- a/Gemfile +++ b/Gemfile @@ -44,7 +44,6 @@ gem 'google-cloud-storage', require: "google/cloud/storage" gem 'ed25519' gem 'bcrypt_pbkdf' # https://github.com/net-ssh/net-ssh/issues/565 gem 'terminal-table' -gem 'newrelic_rpm', require: false gem 'clockwork' gem 'puma-metrics' gem 'puma_worker_killer' diff --git a/Gemfile.lock b/Gemfile.lock index d9ffae8a7..308b0f8f5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -309,7 +309,6 @@ GEM digest net-protocol timeout - newrelic_rpm (8.5.0) nio4r (2.5.8) nokogiri (1.13.3) mini_portile2 (~> 2.8.0) @@ -555,7 +554,6 @@ DEPENDENCIES minitest-reporters mocha mock_redis - newrelic_rpm nokogiri oauth2 parallel diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 0475e322b..3a7878da7 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -59,7 +59,6 @@ import Upload from "../src/javascripts/uploads.js"; import UserTooltip from "../src/javascripts/user_tooltips.js"; import Utility from "../src/javascripts/utility.js"; import Ugoira from "../src/javascripts/ugoira.js" -import NewRelic from "../src/javascripts/new_relic.js"; let Danbooru = {}; Danbooru.Autocomplete = Autocomplete; @@ -87,7 +86,6 @@ Danbooru.Upload = Upload; Danbooru.UserTooltip = UserTooltip; Danbooru.Utility = Utility; Danbooru.Ugoira = Ugoira; -Danbooru.NewRelic = NewRelic; Danbooru.notice = Utility.notice; Danbooru.error = Utility.error; diff --git a/app/javascript/src/javascripts/new_relic.js b/app/javascript/src/javascripts/new_relic.js deleted file mode 100644 index ac5712ed8..000000000 --- a/app/javascript/src/javascripts/new_relic.js +++ /dev/null @@ -1,14 +0,0 @@ -class NewRelic { - static initialize_all() { - /* https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/setcustomattribute-browser-agent-api/ */ - if (typeof window.newrelic === "object") { - window.newrelic.setCustomAttribute("screenWidth", window.screen.width); - window.newrelic.setCustomAttribute("screenHeight", window.screen.height); - window.newrelic.setCustomAttribute("screenResolution", `${window.screen.width}x${window.screen.height}`); - window.newrelic.setCustomAttribute("devicePixelRatio", window.devicePixelRatio); - } - } -} - -NewRelic.initialize_all(); -export default NewRelic; diff --git a/app/logical/danbooru_logger.rb b/app/logical/danbooru_logger.rb index 64d5a800e..51f2624d5 100644 --- a/app/logical/danbooru_logger.rb +++ b/app/logical/danbooru_logger.rb @@ -1,27 +1,25 @@ # frozen_string_literal: true -# The DanbooruLogger class handles logging messages to the Rails log and to NewRelic. +# The DanbooruLogger class handles logging messages to the Rails log and to the APM. # # @see https://guides.rubyonrails.org/debugging_rails_applications.html#the-logger -# @see https://docs.newrelic.com class DanbooruLogger HEADERS = %w[referer sec-fetch-dest sec-fetch-mode sec-fetch-site sec-fetch-user] - # Log a message to the Rails log and to NewRelic. + # Log a message to the Rails log and to the APM. + # # @param message [String] the message to log # @param params [Hash] optional key-value data to log with the message def self.info(message, params = {}) Rails.logger.info(message) - if defined?(::NewRelic) - params = flatten_hash(params).symbolize_keys - ::NewRelic::Agent.record_custom_event(:info, message: message, **params) - end + params = flatten_hash(params).symbolize_keys + log_event(:info, message: message, **params) end - # Log an exception to the Rails log and to NewRelic. The `expected` flag is + # Log an exception to the Rails log and to the APM. The `expected` flag is # used to separate expected exceptions, like search timeouts or auth failures, - # from unexpected exceptions, like runtime errors, in the NewRelic error log. + # from unexpected exceptions, like runtime errors, in the error logs. # # @param message [Exception] the exception to log # @param expected [Boolean] whether the exception was expected @@ -34,12 +32,10 @@ class DanbooruLogger Rails.logger.error("#{exception.class}: #{exception.message}\n#{backtrace}") end - if defined?(::NewRelic) - ::NewRelic::Agent.notice_error(exception, expected: expected, custom_params: params) - end + log_exception(exception, expected: expected, custom_params: params) end - # Log extra HTTP request data to NewRelic. Logs the user's IP, user agent, + # Log extra HTTP request data to the APM. Logs the user's IP, user agent, # request params, and session cookies. # # @param request the HTTP request @@ -84,15 +80,18 @@ class DanbooruLogger def self.add_attributes(prefix, hash) attributes = flatten_hash(hash).transform_keys { |key| "#{prefix}.#{key}" } attributes.delete_if { |key, value| key.end_with?(*Rails.application.config.filter_parameters.map(&:to_s)) } - add_custom_attributes(attributes) + log_attributes(attributes) end private_class_method - # @see https://docs.newrelic.com/docs/using-new-relic/data/customize-data/collect-custom-attributes/#ruby-att - def self.add_custom_attributes(attributes) - return unless defined?(::NewRelic) - ::NewRelic::Agent.add_custom_attributes(attributes) + def self.log_attributes(attributes) + end + + def self.log_exception(exception, expected: false, custom_params: {}) + end + + def self.log_event(level, message: nil, **params) end # flatten_hash({ foo: { bar: { baz: 42 } } }) diff --git a/app/views/layouts/blank.html.erb b/app/views/layouts/blank.html.erb index 8073e813c..068a77491 100644 --- a/app/views/layouts/blank.html.erb +++ b/app/views/layouts/blank.html.erb @@ -1,7 +1,6 @@
- <%= NewRelic::Agent.browser_timing_header rescue "" %>