Files
redux-scraper/config/initializers/good_job.rb
Dylan Knutson 13f078eb34 Add GoodJob metrics integration and update Prometheus configuration
- Introduced a new `GoodJobMetricsWithQueues` class for tracking GoodJob queue counts using Prometheus.
- Updated `application.rb` to include Prometheus exporter dependencies and configuration.
- Added a new `prometheus_exporter.yml` file to manage Prometheus settings across environments.
- Modified `puma.rb` to remove redundant Prometheus instrumentation code.
- Enabled eager loading in the development environment for better performance.
- Updated GoodJob initializer to start the new metrics tracking.

These changes enhance monitoring capabilities for job processing and improve application performance.
2025-01-04 07:23:08 +00:00

49 lines
1.7 KiB
Ruby

# typed: true
Rails.application.configure do
# GoodJob configuration - applies to all environments (including test)
config.good_job.inline_execution_respects_schedule = true
config.good_job.active_record_parent_class = "ReduxApplicationRecord"
config.good_job.retry_on_unhandled_error = true
config.good_job.smaller_number_is_higher_priority = true
# job cleanup config - retain the last 24 hours of jobs
config.good_job.preserve_job_records = true
config.good_job.cleanup_preserved_jobs_before_seconds_ago = 1.day
config.good_job.cleanup_interval_jobs = 100_000
config.good_job.cleanup_interval_seconds = 4.hours
config.good_job.logger = Logger.new(STDOUT)
config.good_job.logger.level = :info
if Rails.env == "worker"
config.good_job.execution_mode = :async
config.good_job.on_thread_error = ->(exception) do
Rails.logger.error("GoodJob exception: #{exception}")
end
else
config.good_job.execution_mode = :external
end
end
ActiveSupport.on_load(:good_job_application_controller) do
T.bind(self, T.class_of(ActionController::Base))
content_security_policy do |policy|
policy.font_src :self, :https, :data, "cdnjs.cloudflare.com"
policy.style_src :self, :https, "cdnjs.cloudflare.com"
policy.style_src_elem :self, :https, "cdnjs.cloudflare.com"
end
Scraper::Metrics::GoodJobMetricsWithQueues.start
end
ActiveSupport.on_load(:good_job_base_record) do
class GoodJob::Execution
has_one :log_lines_collection,
class_name: "::GoodJobExecutionLogLinesCollection",
dependent: :destroy,
inverse_of: :good_job_execution
after_create { Scraper::JobBase.last_good_job_execution = self }
end
end