Module: Appsignal::Integrations::QuePlugin Private

Defined in:
lib/appsignal/integrations/que.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#_run(*args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/appsignal/integrations/que.rb', line 7

def _run(*args)
  transaction =
    Appsignal::Transaction.create(Appsignal::Transaction::BACKGROUND_JOB)

  begin
    Appsignal.instrument("perform_job.que") { super }
  rescue Exception => error # rubocop:disable Lint/RescueException
    transaction.set_error(error)
    raise error
  ensure
    local_attrs = respond_to?(:que_attrs) ? que_attrs : attrs
    transaction.set_action_if_nil("#{local_attrs[:job_class]}#run")
    transaction.add_params_if_nil do
      {
        :arguments => local_attrs[:args]
      }.tap do |hash|
        hash[:keyword_arguments] = local_attrs[:kwargs] if local_attrs.key?(:kwargs)
      end
    end
    transaction.add_tags(
      "id" => local_attrs[:job_id] || local_attrs[:id],
      "queue" => local_attrs[:queue],
      "run_at" => local_attrs[:run_at].to_s,
      "priority" => local_attrs[:priority],
      "attempts" => local_attrs[:error_count].to_i
    )
    Appsignal::Transaction.complete_current!
  end
end