Class: Appsignal::Rack::EventMiddleware

Inherits:
Events
  • Object
show all
Defined in:
lib/appsignal/rack/event_middleware.rb

Overview

Instrumentation middleware using Rack’s Events module.

A convenience wrapper around our Events middleware, modified to be compatible with streaming bodies, that automatically includes AppSignal’s EventHandler.

We recommend using this in combination with the InstrumentationMiddleware.

This middleware will report the response status code as the ‘response_status` tag on the sample. It will also report the response status as the `response_status` metric.

This middleware will ensure the AppSignal transaction is always completed for every request.

Examples:

Add EventMiddleware to a Rack app

# Add this middleware as the first middleware of an app
use Appsignal::Rack::EventMiddleware

# Then add the InstrumentationMiddleware
use Appsignal::Rack::InstrumentationMiddleware

See Also:

Instance Method Summary collapse

Methods inherited from Events

#call

Constructor Details

#initialize(app) ⇒ EventMiddleware

Returns a new instance of EventMiddleware.



107
108
109
110
111
# File 'lib/appsignal/rack/event_middleware.rb', line 107

def initialize(app)
  super(app, [Appsignal::Rack::EventHandler.new.tap do |handler|
    handler.using_appsignal_event_middleware = true
  end])
end