Skip to content

Commit

Permalink
Merge pull request #311 from alphagov/no-open-telemetry-in-rake
Browse files Browse the repository at this point in the history
GovukAppConfig silences OpenTelemetry log output when running a rake task
  • Loading branch information
KludgeKML committed Aug 21, 2023
2 parents 8d4a43a + 43a61c8 commit 4703501
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased

* GovukAppConfig silences OpenTelemetry log output when running a rake task ([#311](https://github.com/alphagov/govuk_app_config/pull/311))

# 9.0.4

* Fix an issue with Rails.logger being not an instance of ActiveSupport::Logger. Rails expects Rails.logger to have methods that Ruby STD Logger does not provide. e.g. `silence()` ([#309](https://github.com/alphagov/govuk_app_config/pull/309))
Expand Down Expand Up @@ -36,7 +40,7 @@

# 8.0.1

* Change the "source" field in Rails logs from logstasher from string representing IP host address to an empty object.
* Change the "source" field in Rails logs from logstasher from string representing IP host address to an empty object.

# 8.0.0

Expand Down
5 changes: 5 additions & 0 deletions lib/govuk_app_config/govuk_open_telemetry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def self.configure(service_name)
OpenTelemetry::SDK.configure do |config|
config.service_name = service_name
config.use_all # enables all instrumentation!
config.logger = Logger.new(File::NULL) if in_rake_task?
end
end

def self.in_rake_task?
Rails.const_defined?(:Rake) && Rake.application.top_level_tasks.any?
end
end

0 comments on commit 4703501

Please sign in to comment.