Skip to content

Commit

Permalink
Set log_level to :warn for AnalyticsJobs
Browse files Browse the repository at this point in the history
:info is extremely noisy and causes us to exceed our logit.io limit
  • Loading branch information
duncanjbrown committed Sep 16, 2022
1 parent 43f7c07 commit 0c7493b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/dfe/analytics/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class Railtie < Rails::Railtie
app.config.middleware.use DfE::Analytics::Middleware::RequestIdentity
end

initializer 'dfe.analytics.logger' do
ActiveSupport.on_load(:active_job) do
DfE::Analytics::AnalyticsJob.logger = ::Rails.logger.dup.tap { |l| l.level = Logger::WARN }
end
end

config.after_initialize do
# internal gem tests will sometimes suppress this so they can test the
# init process
Expand Down
1 change: 1 addition & 0 deletions lib/dfe/analytics/send_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def self.do(events)

def perform(events)
if DfE::Analytics.log_only?
# Use the Rails logger here as the job's logger is set to :warn by default
Rails.logger.info("DfE::Analytics: #{events.inspect}")
else
response = DfE::Analytics.events_client.insert(events, ignore_unknown: true)
Expand Down

0 comments on commit 0c7493b

Please sign in to comment.