Sha256: cfa973988331a2211c784ddc259811d3057626859b18e24a2b98b12c65ae040d

Contents?: true

Size: 884 Bytes

Versions: 5

Compression:

Stored size: 884 Bytes

Contents

begin
  require "raven"
rescue LoadError
  raise "Can't find 'sentry-raven' gem. Please add it to your Gemfile or install it."
end

module GlassOctopus
  module Middleware
    class Sentry
      def initialize(app)
        @app = app
      end

      # Based on Raven::Rack integration
      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
glass_octopus-2.2.0 lib/glass_octopus/middleware/sentry.rb
glass_octopus-2.1.0 lib/glass_octopus/middleware/sentry.rb
glass_octopus-2.0.0 lib/glass_octopus/middleware/sentry.rb
glass_octopus-1.1.0 lib/glass_octopus/middleware/sentry.rb
glass_octopus-1.0.0 lib/glass_octopus/middleware/sentry.rb