Class: Appsignal::Rack::RailsInstrumentation Private
- Defined in:
- lib/appsignal/rack/rails_instrumentation.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #call(env) ⇒ Object private
- #call_with_appsignal_monitoring(env) ⇒ Object private
-
#initialize(app, options = {}) ⇒ RailsInstrumentation
constructor
private
A new instance of RailsInstrumentation.
- #request_id(env) ⇒ Object private
Constructor Details
#initialize(app, options = {}) ⇒ RailsInstrumentation
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.
Returns a new instance of RailsInstrumentation.
9 10 11 12 13 |
# File 'lib/appsignal/rack/rails_instrumentation.rb', line 9 def initialize(app, = {}) Appsignal.logger.debug "Initializing Appsignal::Rack::RailsInstrumentation" @app = app @options = end |
Instance Method Details
#call(env) ⇒ 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.
15 16 17 18 19 20 21 |
# File 'lib/appsignal/rack/rails_instrumentation.rb', line 15 def call(env) if Appsignal.active? call_with_appsignal_monitoring(env) else @app.call(env) end end |
#call_with_appsignal_monitoring(env) ⇒ 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.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/appsignal/rack/rails_instrumentation.rb', line 23 def call_with_appsignal_monitoring(env) request = ActionDispatch::Request.new(env) transaction = Appsignal::Transaction.create( request_id(env), Appsignal::Transaction::HTTP_REQUEST, request, :params_method => :filtered_parameters ) begin @app.call(env) rescue Exception => error # rubocop:disable Lint/RescueException transaction.set_error(error) raise error ensure controller = env["action_controller.instance"] if controller transaction.set_action_if_nil("#{controller.class}##{controller.action_name}") end transaction.set_http_or_background_queue_start transaction.("path", request.path) begin transaction.("method", request.request_method) rescue => error Appsignal.logger.error("Unable to report HTTP request method: '#{error}'") end Appsignal::Transaction.complete_current! end end |
#request_id(env) ⇒ 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.
52 53 54 |
# File 'lib/appsignal/rack/rails_instrumentation.rb', line 52 def request_id(env) env["action_dispatch.request_id"] || SecureRandom.uuid end |