Class: Ears::Middlewares::Appsignal

Inherits:
Ears::Middleware show all
Defined in:
lib/ears/middlewares/appsignal.rb

Overview

A middleware that automatically wraps Consumer#work in an Appsignal transaction.

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Appsignal

Returns a new instance of Appsignal.

Parameters:

  • opts (Hash)

    The options for the middleware.

Options Hash (opts):

  • :class_name (String)

    The name of the class you want to monitor.

  • :namespace (String) — default: 'background'

    The namespace in which the action should appear.



10
11
12
13
14
# File 'lib/ears/middlewares/appsignal.rb', line 10

def initialize(opts)
  super()
  @class_name = opts.fetch(:class_name)
  @namespace = opts.fetch(:namespace, 'background')
end

Instance Method Details

#call(delivery_info, metadata, payload, app) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/ears/middlewares/appsignal.rb', line 16

def call(delivery_info, , payload, app)
  start_transaction do
    begin
      app.call(delivery_info, , payload)
    rescue => e
      ::Appsignal.set_error(e)
      raise
    end
  end
end