Module: Appsignal::Integrations::HanamiIntegration

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

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/appsignal/integrations/hanami.rb', line 27

def call(env)
  params = ::Hanami::Action::BaseParams.new(env)
  request = ::Hanami::Action::Request.new(
    :env => env,
    :params => params,
    :sessions_enabled => true
  )

  transaction = Appsignal::Transaction.create(
    SecureRandom.uuid,
    Appsignal::Transaction::HTTP_REQUEST,
    request
  )

  begin
    Appsignal.instrument("process_action.hanami") do
      super.tap do |response|
        transaction.("status", response.status.to_s)
      end
    end
  rescue Exception => error # rubocop:disable Lint/RescueException
    transaction.set_error(error)
    transaction.("status", "500")
    raise error
  ensure
    transaction.params = request.params.to_h
    transaction.set_action_if_nil(self.class.name)
    transaction.("path", request.path)
    transaction.("method", request.request_method)
    transaction.set_http_or_background_queue_start
    Appsignal::Transaction.complete_current!
  end
end