diff --git a/Gemfile b/Gemfile index 2c8b8963714..bbb0cadf668 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem "dogstatsd-ruby", "~> 5.5" gem "google-protobuf", "~> 4.27" gem "faraday", "~> 2.10" gem "faraday-retry", "~> 2.2" -gem "good_job", "~> 3.29" +gem "good_job", "~> 3.99" gem "gravtastic", "~> 3.2" gem "honeybadger", "~> 5.5.1", require: false # see https://github.com/rubygems/rubygems.org/pull/4598 gem "http_accept_language", "~> 2.1" diff --git a/Gemfile.lock b/Gemfile.lock index f591c0c8988..e56114b870d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -267,7 +267,7 @@ GEM ffi (~> 1.0) globalid (1.2.1) activesupport (>= 6.1) - good_job (3.29.5) + good_job (3.99.1) activejob (>= 6.0.0) activerecord (>= 6.0.0) concurrent-ruby (>= 1.0.2) @@ -826,7 +826,7 @@ DEPENDENCIES faraday-retry (~> 2.2) faraday_middleware-aws-sigv4 (~> 1.0) gem_server_conformance (~> 0.1.4) - good_job (~> 3.29) + good_job (~> 3.99) google-protobuf (~> 4.27) gravtastic (~> 3.2) groupdate (~> 6.2) @@ -1005,7 +1005,7 @@ CHECKSUMS gem_server_conformance (0.1.4) sha256=ee404d5405eabcb6f7ab440d2193177375481a77bfa0ec3106165dd6c8e733bb get_process_mem (0.2.7) sha256=4afd3c3641dd6a817c09806c7d6d509d8a9984512ac38dea8b917426bbf77eba globalid (1.2.1) sha256=70bf76711871f843dbba72beb8613229a49429d1866828476f9c9d6ccc327ce9 - good_job (3.29.5) sha256=3d71236c7e89b9678ba0cf16d6a93b9ee2ff12795959a0c10f77fd52f6479a13 + good_job (3.99.1) sha256=7d3869d8a8ee8ef7048fee5d746f41c21987b7822c20038a2f773036bef0830a google-protobuf (4.27.2) sha256=9f69eb20acde6e3cf3cd197c09f38911cd7eed5fdf1bf4d4bce4c55e9dc9966f gravtastic (3.2.6) sha256=ef98abcecf7c402b61cff1ae7c50a2c6d97dd22bac21ea9b421ce05bc03d734f groupdate (6.4.0) sha256=65940645bf2a48f9b2d10ab7a1d19bdc78f3c89559d8fce39cea3448a15aec54 diff --git a/config/initializers/statsd.rb b/config/initializers/statsd.rb index 2e91b49bc84..a3721b165bb 100644 --- a/config/initializers/statsd.rb +++ b/config/initializers/statsd.rb @@ -57,8 +57,10 @@ ActiveSupport::Notifications.subscribe("perform_job.good_job") do |event| execution = event.payload[:execution] + # TODO: remove || execution after GoodJob 4 upgrade + job = event.payload[:job] || execution - result = if event.payload[:retried] || execution.retried_good_job_id.present? + result = if event.payload[:retried] || job.retried_good_job_id.present? :retried elsif event.payload[:unhandled_error] :unhandled_error @@ -72,7 +74,7 @@ job_class: execution.serialized_params['job_class'], exception: event.payload.dig(:exception, 0), queue: execution.queue_name, - priority: execution.priority, + priority: job.priority, result: } diff --git a/db/migrate/20240722182907_create_good_job_execution_duration.rb b/db/migrate/20240722182907_create_good_job_execution_duration.rb new file mode 100644 index 00000000000..fef37f07bc1 --- /dev/null +++ b/db/migrate/20240722182907_create_good_job_execution_duration.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class CreateGoodJobExecutionDuration < ActiveRecord::Migration[7.1] + def change + reversible do |dir| + dir.up do + # Ensure this incremental update migration is idempotent + # with monolithic install migration. + return if connection.column_exists?(:good_job_executions, :duration) + end + end + + add_column :good_job_executions, :duration, :interval + end +end diff --git a/db/schema.rb b/db/schema.rb index 295f1ba7ef9..8fbfefc8343 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_07_12_003336) do +ActiveRecord::Schema[7.1].define(version: 2024_07_22_182907) do # These are extensions that must be enabled in order to support this database enable_extension "hstore" enable_extension "pgcrypto" @@ -202,6 +202,7 @@ t.integer "error_event", limit: 2 t.text "error_backtrace", array: true t.uuid "process_id" + t.interval "duration" t.index ["active_job_id", "created_at"], name: "index_good_job_executions_on_active_job_id_and_created_at" t.index ["process_id", "created_at"], name: "index_good_job_executions_on_process_id_and_created_at" end