[Prod] Dump NewRelic

Need to look into alternatives
This commit is contained in:
Earlopain 2024-03-23 20:52:31 +01:00
parent 700bf05ba5
commit e4799d9f83
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
11 changed files with 7 additions and 97 deletions

View File

@ -64,8 +64,3 @@
# JOINER_OAUTH2_CLIENT_SECRET=
# JOINER_GUILD_ID=
# JOINER_FAILED_JOIN_WEBHOOK_URL=
# Enable the NewRelic integration
# NEW_RELIC_AGENT_ENABLED=true
# NEW_RELIC_LICENSE_KEY=your_license_key

View File

@ -28,7 +28,6 @@ gem 'marcel'
gem 'sidekiq-unique-jobs'
gem 'redis'
gem 'request_store'
gem 'newrelic_rpm'
gem "diffy"
gem "rugged"

View File

@ -201,7 +201,6 @@ GEM
net-smtp (0.4.0.1)
net-protocol
netrc (0.11.0)
newrelic_rpm (9.7.1)
nio4r (2.7.0)
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
@ -392,7 +391,6 @@ DEPENDENCIES
mailgun-ruby
marcel
mocha
newrelic_rpm
opensearch-ruby
pg
puma

View File

@ -1,17 +1,13 @@
# frozen_string_literal: true
class DanbooruLogger
def self.log(exception, expected: false, **params)
def self.log(exception, expected: false, **_params)
if expected
Rails.logger.info("#{exception.class}: #{exception.message}")
else
backtrace = Rails.backtrace_cleaner.clean(exception.backtrace).join("\n")
Rails.logger.error("#{exception.class}: #{exception.message}\n#{backtrace}")
end
if defined?(::NewRelic) && !expected
::NewRelic::Agent.notice_error(exception, expected: expected, custom_params: params)
end
end
def self.initialize(user)
@ -19,8 +15,6 @@ class DanbooruLogger
end
def self.add_attributes(**)
return unless defined?(::NewRelic)
::NewRelic::Agent.add_custom_attributes(**)
# noop
end
end

View File

@ -22,7 +22,7 @@ class RelatedTagCalculator
end
def self.calculate_from_sample(tags, sample_size, category_constraint = nil, max_results = MAX_RESULTS)
Post.with_timeout(5_000, [], {:tags => tags}) do
Post.with_timeout(5_000, []) do
sample = Post.sample(tags, sample_size)
posts_with_tags = sample.with_unflattened_tags

View File

@ -210,7 +210,7 @@ class ApplicationRecord < ActiveRecord::Base
connection.execute("SET STATEMENT_TIMEOUT = #{CurrentUser.user.try(:statement_timeout) || 3_000}") unless Rails.env == "test"
end
def with_timeout(n, default_value = nil, new_relic_params = {})
def with_timeout(n, default_value = nil)
connection.execute("SET STATEMENT_TIMEOUT = #{n}") unless Rails.env == "test"
yield
rescue ::ActiveRecord::StatementInvalid => x

View File

@ -117,7 +117,7 @@ class Tag < ApplicationRecord
end
def update_category_post_counts!
Post.with_timeout(30_000, nil, {:tags => name}) do
Post.with_timeout(30_000, nil) do
Post.sql_raw_tag_match(name).find_each do |post|
post.set_tag_counts(disable_cache: false)
args = TagCategory::CATEGORIES.to_h { |x| ["tag_count_#{x}", post.send("tag_count_#{x}")] }.update("tag_count" => post.tag_count)

View File

@ -9,9 +9,9 @@
Rails.application.configure do
config.content_security_policy do |policy|
policy.default_src :self
policy.script_src :self, 'ads.dragonfru.it', 'js-agent.newrelic.com', 'bam.nr-data.net', 'https://www.google.com/recaptcha/', 'https://www.gstatic.com/recaptcha/', 'https://www.recaptcha.net/'
policy.script_src :self, "ads.dragonfru.it", "https://www.google.com/recaptcha/", "https://www.gstatic.com/recaptcha/", "https://www.recaptcha.net/"
policy.style_src :self, :unsafe_inline
policy.connect_src :self, 'ads.dragonfru.it', 'bam.nr-data.net', 'plausible.dragonfru.it'
policy.connect_src :self, "ads.dragonfru.it", "plausible.dragonfru.it"
policy.object_src :self, 'static1.e621.net', 'static1.e926.net'
policy.media_src :self, 'static1.e621.net', 'static1.e926.net'
policy.frame_ancestors :none

View File

@ -1,72 +0,0 @@
#
# This file configures the New Relic Agent. New Relic monitors Ruby, Java,
# .NET, PHP, Python, Node, and Go applications with deep visibility and low
# overhead. For more information, visit www.newrelic.com.
#
# Generated October 28, 2022
#
# This configuration file is custom generated for NewRelic Administration
#
# For full documentation of agent configuration options, please refer to
# https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration
common: &default_settings
# Required license key associated with your New Relic account.
# Set with NEW_RELIC_LICENSE_KEY
license_key: ''
# Your application name. Renaming here affects where data displays in New
# Relic. For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications
app_name: 'E6ng'
distributed_tracing:
enabled: true
# To disable the agent regardless of other settings, uncomment the following:
# agent_enabled: false
# Logging level for log/newrelic_agent.log
log_level: info
browser_monitoring:
auto_instrument: false
attributes:
include: request.parameters.*
application_logging:
# If `true`, all logging-related features for the agent can be enabled or disabled
# independently. If `false`, all logging-related features are disabled.
enabled: true
forwarding:
# If `true`, the agent captures log records emitted by this application.
enabled: true
# Defines the maximum number of log records to buffer in memory at a time.
max_samples_stored: 10000
metrics:
# If `true`, the agent captures metrics related to logging for this application.
enabled: true
local_decorating:
# If `true`, the agent decorates logs with metadata to link to entities, hosts, traces, and spans.
# This requires a log forwarder to send your log files to New Relic.
# This should not be used when forwarding is enabled.
enabled: false
# Environment-specific settings are in this section.
# RAILS_ENV or RACK_ENV (as appropriate) is used to determine the environment.
# If your application has other named environments, configure them here.
development:
<<: *default_settings
app_name: 'E6ng (Development)'
test:
<<: *default_settings
# It doesn't make sense to report to New Relic from automated test runs.
monitor_mode: false
staging:
<<: *default_settings
app_name: 'E6ng (Staging)'
production:
<<: *default_settings

View File

@ -8,8 +8,6 @@ x-environment: &common-env
DANBOORU_IQDB_SERVER: http://iqdb:5588
DANBOORU_DISCORD_SITE: http://localhost:8000
DANBOORU_DISCORD_SECRET: super_secret_for_url_discord
NEW_RELIC_AGENT_ENABLED: ${NEW_RELIC_AGENT_ENABLED:-false}
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY:-}
# These are just development secrets, do not use them in production
DANBOORU_PROTECTED_FILE_SECRET: 6686a6413d90c43d5e82403ef271ec25d13cc24e3bfcdd094e73d1eff22a3567
DANBOORU_REPLACEMENT_FILE_SECRET: b35bc54cdc0d0436fc5867c7ef88f9b10a37ae20a06b37e67614fe60019d7bb1

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require "tasks/newrelic" if defined?(NewRelic)
namespace :maintenance do
desc "Run daily maintenance jobs"
task daily: :environment do