Module: Sidekiq::Form526JobStatusTracker::JobTracker
- Extended by:
- ActiveSupport::Concern, BackupSubmission
- Includes:
- SentryLogging
- Defined in:
- lib/sidekiq/form526_job_status_tracker/job_tracker.rb
Overview
rubocop:disable Metrics/ModuleLength
Constant Summary collapse
- STATSD_KEY_PREFIX =
'worker.evss.submit_form526.job_status'
Instance Method Summary collapse
-
#job_success ⇒ Object
Metrics and logging for when the job succeeds.
-
#job_try ⇒ Object
Metrics and logging for each Sidekiq try.
-
#non_retryable_error_handler(error) ⇒ Object
Metrics and logging for any non-retryable errors that occurred.
-
#retryable_error_handler(error) ⇒ Object
Metrics and logging for any retryable errors that occurred.
-
#with_tracking(job_title, saved_claim_id, submission_id, is_bdd = nil) ⇒ Object
Code wrapped by this block will run between the #job_try and #job_success methods.
Methods included from BackupSubmission
send_backup_submission_if_enabled
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Instance Method Details
#job_success ⇒ Object
Metrics and logging for when the job succeeds
110 111 112 113 114 115 116 |
# File 'lib/sidekiq/form526_job_status_tracker/job_tracker.rb', line 110 def job_success upsert_job_status(Form526JobStatus::STATUS[:success]) log_info('success') metrics.increment_success(@is_bdd) rescue => e ::Rails.logger.error('error tracking job success', error: e, class: klass, trace: e.backtrace) end |
#job_try ⇒ Object
Metrics and logging for each Sidekiq try
100 101 102 103 104 105 106 |
# File 'lib/sidekiq/form526_job_status_tracker/job_tracker.rb', line 100 def job_try upsert_job_status(Form526JobStatus::STATUS[:try]) log_info('try') metrics.increment_try rescue => e ::Rails.logger.error('error tracking job try', error: e, class: klass) end |
#non_retryable_error_handler(error) ⇒ Object
Metrics and logging for any non-retryable errors that occurred. Non-retryable errors will always fail, e.g. an ArgumentError in the job class
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/sidekiq/form526_job_status_tracker/job_tracker.rb', line 130 def non_retryable_error_handler(error) upsert_job_status(Form526JobStatus::STATUS[:non_retryable_error], error) error_class = error.class = error. JobTracker.send_backup_submission_if_enabled(form526_submission_id: @status_submission_id, job_class: klass, job_id: jid, error_class:, error_message:) log_exception_to_sentry(error, status: :non_retryable_error, jid:) log_error('non_retryable_error', error) metrics.increment_non_retryable(error, @is_bdd) end |
#retryable_error_handler(error) ⇒ Object
Metrics and logging for any retryable errors that occurred. Retryable are system recoverable, e.g. an upstream http timeout
121 122 123 124 125 |
# File 'lib/sidekiq/form526_job_status_tracker/job_tracker.rb', line 121 def retryable_error_handler(error) upsert_job_status(Form526JobStatus::STATUS[:retryable_error], error) log_error('retryable_error', error) metrics.increment_retryable(error, @is_bdd) end |
#with_tracking(job_title, saved_claim_id, submission_id, is_bdd = nil) ⇒ Object
Code wrapped by this block will run between the #job_try and #job_success methods
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/sidekiq/form526_job_status_tracker/job_tracker.rb', line 81 def with_tracking(job_title, saved_claim_id, submission_id, is_bdd = nil) @status_job_title = job_title @status_saved_claim_id = saved_claim_id @status_submission_id = submission_id @is_bdd = is_bdd job_try begin yield rescue exception_raised = true raise ensure job_success unless exception_raised end end |