app/workers/evss/disability_compensation_form/job_status.rb
def job_exhausted(msg, statsd_key_prefix)
          job_id = msg['jid']
          error_class = msg['error_class']
          error_message = msg['error_message']
          timestamp = Time.now.utc

          values = {
            form526_submission_id: msg['args'].first,
            job_id: job_id,
            job_class: msg['class'].demodulize,
            status: Form526JobStatus::STATUS[:exhausted],
            error_class: error_class,
            error_message: error_message,
            bgjob_errors: {},
            updated_at: timestamp
          }

          form_job_status = Form526JobStatus.find_by(job_id: job_id)
          bgjob_errors = form_job_status.bgjob_errors || {}
          new_error = {
            "#{timestamp.to_i}": {
              caller_method: __method__.to_s,
              error_class: error_class,
              error_message: error_message,
              timestamp: timestamp
            }
          }
          bgjob_errors.merge!(new_error)
          values[:bgjob_errors] = bgjob_errors

          Form526JobStatus.upsert(values, unique_by: :job_id)

          Rails.logger.error(
            'Form526 Exhausted', submission_id: msg['args'].first,
                                 job_id: job_id,
                                 error_class: error_class,
                                 error_message: error_message
          )
          Metrics.new(statsd_key_prefix).increment_exhausted
        rescue => e
          Rails.logger.error('error tracking job exhausted', error: e, class: msg['class'].demodulize)
        end
# Callback that fires when a job has exhausted its retries
#
# @param msg [Hash] The message payload from Sidekiq
#
# rubocop:disable Metrics/MethodLength
Callback that fires when a job has exhausted its retries
Callback that fires when a job has exhausted its retries
def job_exhausted(msg, statsd_key_prefix)
          job_id = msg['jid']
          error_class = msg['error_class']
          error_message = msg['error_message']
          timestamp = Time.now.utc
          values = {
            form526_submission_id: msg['args'].first,
            job_id: job_id,
            job_class: msg['class'].demodulize,
            status: Form526JobStatus::STATUS[:exhausted],
            error_class: error_class,
            error_message: error_message,
            bgjob_errors: {},
            updated_at: timestamp
          }
          form_job_status = Form526JobStatus.find_by(job_id: job_id)
          bgjob_errors = form_job_status.bgjob_errors || {}
          new_error = {
            "#{timestamp.to_i}": {
              caller_method: __method__.to_s,
              error_class: error_class,
              error_message: error_message,
              timestamp: timestamp
            }
          }
          bgjob_errors.merge!(new_error)
          values[:bgjob_errors] = bgjob_errors
          Form526JobStatus.upsert(values, unique_by: :job_id)
          Rails.logger.error(
            'Form526 Exhausted', submission_id: msg['args'].first,
                                 job_id: job_id,
                                 error_class: error_class,
                                 error_message: error_message
          )
          Metrics.new(statsd_key_prefix).increment_exhausted
        rescue => e
          Rails.logger.error('error tracking job exhausted', error: e, class: msg['class'].demodulize)
        end
def job_exhausted ( msg , statsd_key_prefix ) job_id = msg [ 'jid' ] error_class = msg [ 'error_class' ] error_message = msg [ 'error_message' ] timestamp = Time . now . utc values = { form526_submission_id : msg [ 'args' ] . first , job_id : job_id , job_class : msg [ 'class' ] . demodulize , status : Form526JobStatus :: STATUS [ :exhausted ] , error_class : error_class , error_message : error_message , bgjob_errors : { } , updated_at : timestamp } form_job_status = Form526JobStatus . find_by ( job_id : job_id ) bgjob_errors = form_job_status . bgjob_errors || { } new_error = { "#{timestamp.to_i}" : { caller_method : __method__ . to_s , error_class : error_class , error_message : error_message , timestamp : timestamp } } bgjob_errors . merge! ( new_error ) values [ :bgjob_errors ] = bgjob_errors Form526JobStatus . upsert ( values , unique_by : :job_id ) Rails . logger . error ( 'Form526 Exhausted' , submission_id : msg [ 'args' ] . first , job_id : job_id , error_class : error_class , error_message : error_message ) Metrics . new ( statsd_key_prefix ) . increment_exhausted rescue => e Rails . logger . error ( 'error tracking job exhausted' , error : e , class : msg [ 'class' ] . demodulize ) end
Callback that fires when a job has exhausted its retries
Callback that fires when a job has exhausted its retries
msg
The message payload from Sidekiq rubocop:disable Metrics/MethodLength
The message payload from Sidekiq rubocop : disable Metrics / MethodLength
statsd_key_prefix