Skip to content

Commit

Permalink
Prevent Prometheus initialization during i18n export
Browse files Browse the repository at this point in the history
Fixes CODEOCEAN-157
  • Loading branch information
MrSerth committed Oct 14, 2024
1 parent d146258 commit 64efb67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/initializers/prometheus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

return unless CodeOcean::Config.new(:code_ocean).read[:prometheus_exporter][:enabled] && !defined?(Rails::Console)
return if %w[db: assets:].any? {|task| Rake.application.top_level_tasks.to_s.include?(task) }
return if %w[i18n].any?(File.basename($PROGRAM_NAME))

# Add metric callbacks to all models
ActiveSupport.on_load :active_record do
Expand Down
4 changes: 3 additions & 1 deletion lib/prometheus/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ module Controller

class << self
def initialize_metrics
return unless CodeOcean::Config.new(:code_ocean).read[:prometheus_exporter][:enabled] && defined?(::Rails::Console).blank?
return unless CodeOcean::Config.new(:code_ocean).read[:prometheus_exporter][:enabled] && !defined?(Rails::Console)
return if %w[db: assets:].any? {|task| Rake.application.top_level_tasks.to_s.include?(task) }
return if %w[i18n].any?(File.basename($PROGRAM_NAME))

register_metrics
Rails.application.executor.wrap do
Expand Down

0 comments on commit 64efb67

Please sign in to comment.