class GlassOctopus::Middleware::Sentry

Public Class Methods

new(app) click to toggle source
# File lib/glass_octopus/middleware/sentry.rb, line 10
def initialize(app)
  @app = app
end

Public Instance Methods

call(ctx) click to toggle source

Based on Raven::Rack integration

# File lib/glass_octopus/middleware/sentry.rb, line 15
def call(ctx)
  # clear context at the beginning of the processing to ensure a clean slate
  Raven::Context.clear!
  started_at = Time.now

  begin
    @app.call(ctx)
  rescue Raven::Error
    raise # Don't capture Raven errors
  rescue Exception => ex
    Raven.logger.debug("Collecting %p: %s" % [ ex.class, ex.message ])
    Raven.capture_exception(ex, :extra => { :message => ctx.message.to_h },
                                :time_spent => Time.now - started_at)
    raise
  end
end