Class: AppsignalExtensions::Middleware
- Inherits:
-
Object
- Object
- AppsignalExtensions::Middleware
- Defined in:
- lib/appsignal_extensions/middleware.rb
Overview
Used to open an Appsignal transaction, but to let the callee close it when it is done. The standard Rack middleware for Appsignal closes the transaction as soon as the response triplet gets returned, we need to keep the transaction open as long as the response is being read.
Defined Under Namespace
Classes: Close, NullTransaction, TransactionClosingBody
Instance Method Summary collapse
-
#call(env) ⇒ Array
Calls the application, captures errors, sets up wrappers and so forth.
-
#initialize(app) ⇒ Middleware
constructor
Creates a new Appsignal middleware handler with the given Rack app as a callee.
Constructor Details
#initialize(app) ⇒ Middleware
Creates a new Appsignal middleware handler with the given Rack app as a callee
64 65 66 |
# File 'lib/appsignal_extensions/middleware.rb', line 64 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Array
Calls the application, captures errors, sets up wrappers and so forth
72 73 74 75 76 77 78 79 80 |
# File 'lib/appsignal_extensions/middleware.rb', line 72 def call(env) request = ::Rack::Request.new(env) env['action_dispatch.request_id'] ||= SecureRandom.uuid if Appsignal.active? call_with_appsignal(env, request) else call_with_null_transaction(env, request) end end |