forked from e621ng/e621ng
[Prod] Dump NewRelic
Need to look into alternatives
This commit is contained in:
parent
700bf05ba5
commit
e4799d9f83
@ -64,8 +64,3 @@
|
|||||||
# JOINER_OAUTH2_CLIENT_SECRET=
|
# JOINER_OAUTH2_CLIENT_SECRET=
|
||||||
# JOINER_GUILD_ID=
|
# JOINER_GUILD_ID=
|
||||||
# JOINER_FAILED_JOIN_WEBHOOK_URL=
|
# JOINER_FAILED_JOIN_WEBHOOK_URL=
|
||||||
|
|
||||||
# Enable the NewRelic integration
|
|
||||||
|
|
||||||
# NEW_RELIC_AGENT_ENABLED=true
|
|
||||||
# NEW_RELIC_LICENSE_KEY=your_license_key
|
|
||||||
|
1
Gemfile
1
Gemfile
@ -28,7 +28,6 @@ gem 'marcel'
|
|||||||
gem 'sidekiq-unique-jobs'
|
gem 'sidekiq-unique-jobs'
|
||||||
gem 'redis'
|
gem 'redis'
|
||||||
gem 'request_store'
|
gem 'request_store'
|
||||||
gem 'newrelic_rpm'
|
|
||||||
|
|
||||||
gem "diffy"
|
gem "diffy"
|
||||||
gem "rugged"
|
gem "rugged"
|
||||||
|
@ -201,7 +201,6 @@ GEM
|
|||||||
net-smtp (0.4.0.1)
|
net-smtp (0.4.0.1)
|
||||||
net-protocol
|
net-protocol
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
newrelic_rpm (9.7.1)
|
|
||||||
nio4r (2.7.0)
|
nio4r (2.7.0)
|
||||||
nokogiri (1.16.0)
|
nokogiri (1.16.0)
|
||||||
mini_portile2 (~> 2.8.2)
|
mini_portile2 (~> 2.8.2)
|
||||||
@ -392,7 +391,6 @@ DEPENDENCIES
|
|||||||
mailgun-ruby
|
mailgun-ruby
|
||||||
marcel
|
marcel
|
||||||
mocha
|
mocha
|
||||||
newrelic_rpm
|
|
||||||
opensearch-ruby
|
opensearch-ruby
|
||||||
pg
|
pg
|
||||||
puma
|
puma
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class DanbooruLogger
|
class DanbooruLogger
|
||||||
def self.log(exception, expected: false, **params)
|
def self.log(exception, expected: false, **_params)
|
||||||
if expected
|
if expected
|
||||||
Rails.logger.info("#{exception.class}: #{exception.message}")
|
Rails.logger.info("#{exception.class}: #{exception.message}")
|
||||||
else
|
else
|
||||||
backtrace = Rails.backtrace_cleaner.clean(exception.backtrace).join("\n")
|
backtrace = Rails.backtrace_cleaner.clean(exception.backtrace).join("\n")
|
||||||
Rails.logger.error("#{exception.class}: #{exception.message}\n#{backtrace}")
|
Rails.logger.error("#{exception.class}: #{exception.message}\n#{backtrace}")
|
||||||
end
|
end
|
||||||
|
|
||||||
if defined?(::NewRelic) && !expected
|
|
||||||
::NewRelic::Agent.notice_error(exception, expected: expected, custom_params: params)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.initialize(user)
|
def self.initialize(user)
|
||||||
@ -19,8 +15,6 @@ class DanbooruLogger
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.add_attributes(**)
|
def self.add_attributes(**)
|
||||||
return unless defined?(::NewRelic)
|
# noop
|
||||||
|
|
||||||
::NewRelic::Agent.add_custom_attributes(**)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ class RelatedTagCalculator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.calculate_from_sample(tags, sample_size, category_constraint = nil, max_results = MAX_RESULTS)
|
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)
|
sample = Post.sample(tags, sample_size)
|
||||||
posts_with_tags = sample.with_unflattened_tags
|
posts_with_tags = sample.with_unflattened_tags
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ class ApplicationRecord < ActiveRecord::Base
|
|||||||
connection.execute("SET STATEMENT_TIMEOUT = #{CurrentUser.user.try(:statement_timeout) || 3_000}") unless Rails.env == "test"
|
connection.execute("SET STATEMENT_TIMEOUT = #{CurrentUser.user.try(:statement_timeout) || 3_000}") unless Rails.env == "test"
|
||||||
end
|
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"
|
connection.execute("SET STATEMENT_TIMEOUT = #{n}") unless Rails.env == "test"
|
||||||
yield
|
yield
|
||||||
rescue ::ActiveRecord::StatementInvalid => x
|
rescue ::ActiveRecord::StatementInvalid => x
|
||||||
|
@ -117,7 +117,7 @@ class Tag < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_category_post_counts!
|
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.sql_raw_tag_match(name).find_each do |post|
|
||||||
post.set_tag_counts(disable_cache: false)
|
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)
|
args = TagCategory::CATEGORIES.to_h { |x| ["tag_count_#{x}", post.send("tag_count_#{x}")] }.update("tag_count" => post.tag_count)
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
config.content_security_policy do |policy|
|
config.content_security_policy do |policy|
|
||||||
policy.default_src :self
|
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.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.object_src :self, 'static1.e621.net', 'static1.e926.net'
|
||||||
policy.media_src :self, 'static1.e621.net', 'static1.e926.net'
|
policy.media_src :self, 'static1.e621.net', 'static1.e926.net'
|
||||||
policy.frame_ancestors :none
|
policy.frame_ancestors :none
|
||||||
|
@ -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
|
|
@ -8,8 +8,6 @@ x-environment: &common-env
|
|||||||
DANBOORU_IQDB_SERVER: http://iqdb:5588
|
DANBOORU_IQDB_SERVER: http://iqdb:5588
|
||||||
DANBOORU_DISCORD_SITE: http://localhost:8000
|
DANBOORU_DISCORD_SITE: http://localhost:8000
|
||||||
DANBOORU_DISCORD_SECRET: super_secret_for_url_discord
|
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
|
# These are just development secrets, do not use them in production
|
||||||
DANBOORU_PROTECTED_FILE_SECRET: 6686a6413d90c43d5e82403ef271ec25d13cc24e3bfcdd094e73d1eff22a3567
|
DANBOORU_PROTECTED_FILE_SECRET: 6686a6413d90c43d5e82403ef271ec25d13cc24e3bfcdd094e73d1eff22a3567
|
||||||
DANBOORU_REPLACEMENT_FILE_SECRET: b35bc54cdc0d0436fc5867c7ef88f9b10a37ae20a06b37e67614fe60019d7bb1
|
DANBOORU_REPLACEMENT_FILE_SECRET: b35bc54cdc0d0436fc5867c7ef88f9b10a37ae20a06b37e67614fe60019d7bb1
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "tasks/newrelic" if defined?(NewRelic)
|
|
||||||
|
|
||||||
namespace :maintenance do
|
namespace :maintenance do
|
||||||
desc "Run daily maintenance jobs"
|
desc "Run daily maintenance jobs"
|
||||||
task daily: :environment do
|
task daily: :environment do
|
||||||
|
Loading…
Reference in New Issue
Block a user