sentry-raven 2.5.3 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile +5 -2
- data/README.md +18 -34
- data/changelog.md +13 -0
- data/docs/config.rst +3 -3
- data/docs/context.rst +1 -0
- data/docs/integrations/heroku.rst +11 -0
- data/docs/integrations/index.rst +5 -4
- data/lib/raven/breadcrumbs.rb +2 -0
- data/lib/raven/cli.rb +29 -28
- data/lib/raven/configuration.rb +36 -13
- data/lib/raven/event.rb +6 -3
- data/lib/raven/integrations/rack.rb +3 -1
- data/lib/raven/integrations/rails.rb +6 -5
- data/lib/raven/integrations/rails/active_job.rb +42 -20
- data/lib/raven/integrations/sidekiq.rb +2 -1
- data/lib/raven/processor/sanitizedata.rb +10 -4
- data/lib/raven/utils/deep_merge.rb +1 -1
- data/lib/raven/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f9a90db025f175635bb089674602bd66c1d5dfe1
         | 
| 4 | 
            +
              data.tar.gz: 44d3c2baa95de9c91ebc5de66967a8046e1ce8ae
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a8a454427885043f2647bd4cb74d8d9856187fea01f0830c30ffaf32c97024dc8705e7f59edcf2008890138501da5459fa1786bcca89813cff7e493e318d98d3
         | 
| 7 | 
            +
              data.tar.gz: e6d8d7c3f3abfb12168a5d023eed5b8858e40a145c9e90426c3e759eb58d88713eb2bc1a079b68ae6cef9d80fc3f24425d33ce036451e0df6aaa360916c05bf1
         | 
    
        data/.travis.yml
    CHANGED
    
    | @@ -31,9 +31,9 @@ matrix: | |
| 31 31 | 
             
                  env: RAILS_VERSION=4
         | 
| 32 32 | 
             
                - rvm: jruby-1.7.27
         | 
| 33 33 | 
             
                  env: JRUBY_OPTS="--dev" RAILS_VERSION=4
         | 
| 34 | 
            -
                - rvm: jruby-9.1. | 
| 34 | 
            +
                - rvm: jruby-9.1.12.0
         | 
| 35 35 | 
             
                  env: JRUBY_OPTS="--dev -J-Djruby.launch.inproc=true -J-Xmx1024M" RAILS_VERSION=4
         | 
| 36 | 
            -
                - rvm: jruby-9.1. | 
| 36 | 
            +
                - rvm: jruby-9.1.12.0
         | 
| 37 37 | 
             
                  env: JRUBY_OPTS="--dev -J-Djruby.launch.inproc=true -J-Xmx1024M" RAILS_VERSION=5
         | 
| 38 38 | 
             
                - rvm: ruby-head
         | 
| 39 39 | 
             
                  env: RAILS_VERSION=0
         | 
    
        data/Gemfile
    CHANGED
    
    | @@ -4,8 +4,12 @@ gemspec | |
| 4 4 |  | 
| 5 5 | 
             
            if ENV["RAILS_VERSION"] && (ENV["RAILS_VERSION"].to_i == 4)
         | 
| 6 6 | 
             
              gem "rails", "< 5"
         | 
| 7 | 
            -
             | 
| 7 | 
            +
              gem "rspec-rails"
         | 
| 8 | 
            +
            elsif ENV["RAILS_VERSION"] && (ENV["RAILS_VERSION"].to_i == 0)
         | 
| 9 | 
            +
              # no-op. No Rails.
         | 
| 10 | 
            +
            else
         | 
| 8 11 | 
             
              gem "rails", "< 6"
         | 
| 12 | 
            +
              gem "rspec-rails"
         | 
| 9 13 | 
             
            end
         | 
| 10 14 |  | 
| 11 15 | 
             
            if RUBY_VERSION < '2.0'
         | 
| @@ -25,6 +29,5 @@ gem "ruby-prof", platform: :mri | |
| 25 29 | 
             
            gem "rake"
         | 
| 26 30 | 
             
            gem "rubocop", "~> 0.41.1"
         | 
| 27 31 | 
             
            gem "rspec"
         | 
| 28 | 
            -
            gem "rspec-rails"
         | 
| 29 32 | 
             
            gem "timecop"
         | 
| 30 33 | 
             
            gem "test-unit", platform: :mri if RUBY_VERSION > '2.2'
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,9 +1,17 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            <p align="center">
         | 
| 2 | 
            +
              <img src="https://cdn.rawgit.com/getsentry/raven-python/1e525422/docs/_static/logo.png">
         | 
| 3 | 
            +
            </p>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # Raven-Ruby, the Ruby Client for Sentry
         | 
| 2 6 |  | 
| 3 7 | 
             
            [](https://rubygems.org/gems/sentry-raven)
         | 
| 4 8 | 
             
            [](https://travis-ci.org/getsentry/raven-ruby)
         | 
| 9 | 
            +
            [](https://rubygems.org/gems/sentry-raven/)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
             | 
| 12 | 
            +
            [Documentation](https://docs.getsentry.com/hosted/clients/ruby/) | [Bug Tracker](https://github.com/getsentry/raven-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
         | 
| 5 13 |  | 
| 6 | 
            -
             | 
| 14 | 
            +
            The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
         | 
| 7 15 |  | 
| 8 16 | 
             
            ## Requirements
         | 
| 9 17 |  | 
| @@ -32,15 +40,15 @@ Raven.configure do |config| | |
| 32 40 | 
             
            end
         | 
| 33 41 | 
             
            ```
         | 
| 34 42 |  | 
| 35 | 
            -
            ### Raven doesn't report some kinds of data by default | 
| 43 | 
            +
            ### Raven doesn't report some kinds of data by default
         | 
| 36 44 |  | 
| 37 | 
            -
            Raven ignores some exceptions by default - most of these are related to 404s or controller actions not being found. [For a complete list, see the `IGNORE_DEFAULT` constant](https://github.com/getsentry/raven-ruby/blob/master/lib/raven/configuration.rb).
         | 
| 45 | 
            +
            **Raven ignores some exceptions by default** - most of these are related to 404s or controller actions not being found. [For a complete list, see the `IGNORE_DEFAULT` constant](https://github.com/getsentry/raven-ruby/blob/master/lib/raven/configuration.rb).
         | 
| 38 46 |  | 
| 39 47 | 
             
            Raven doesn't report POST data or cookies by default. In addition, it will attempt to remove any obviously sensitive data, such as credit card or Social Security numbers. For more information about how Sentry processes your data, [check out the documentation on the `processors` config setting.](https://docs.getsentry.com/hosted/clients/ruby/config/)
         | 
| 40 48 |  | 
| 41 | 
            -
            ###  | 
| 49 | 
            +
            ### Usage
         | 
| 42 50 |  | 
| 43 | 
            -
            If you use Rails, you're already done - no more configuration required | 
| 51 | 
            +
            **If you use Rails, you're already done - no more configuration required!** Check [Integrations](https://docs.getsentry.com/hosted/clients/ruby/integrations/) for more details on other gems Sentry integrates with automatically.
         | 
| 44 52 |  | 
| 45 53 | 
             
            Otherwise, Raven supports two methods of capturing exceptions:
         | 
| 46 54 |  | 
| @@ -61,29 +69,6 @@ end | |
| 61 69 |  | 
| 62 70 | 
             
            You're all set - but there's a few more settings you may want to know about too!
         | 
| 63 71 |  | 
| 64 | 
            -
            #### DSN
         | 
| 65 | 
            -
             | 
| 66 | 
            -
            While we advise that you set your Sentry DSN through the `SENTRY_DSN` environment
         | 
| 67 | 
            -
            variable, there are two other configuration settings for controlling Raven:
         | 
| 68 | 
            -
             | 
| 69 | 
            -
            ```ruby
         | 
| 70 | 
            -
            # DSN can be configured as a config setting instead.
         | 
| 71 | 
            -
            # Place in config/initializers or similar.
         | 
| 72 | 
            -
            Raven.configure do |config|
         | 
| 73 | 
            -
              config.dsn = 'your_dsn'
         | 
| 74 | 
            -
            end
         | 
| 75 | 
            -
            ```
         | 
| 76 | 
            -
             | 
| 77 | 
            -
            And, while not necessary if using `SENTRY_DSN`, you can also provide an `environments`
         | 
| 78 | 
            -
            setting. Raven will only capture events when `RACK_ENV` or `RAILS_ENV` matches
         | 
| 79 | 
            -
            an environment in the list.
         | 
| 80 | 
            -
             | 
| 81 | 
            -
            ```ruby
         | 
| 82 | 
            -
            Raven.configure do |config|
         | 
| 83 | 
            -
              config.environments = %w[staging production]
         | 
| 84 | 
            -
            end
         | 
| 85 | 
            -
            ```
         | 
| 86 | 
            -
             | 
| 87 72 | 
             
            #### async
         | 
| 88 73 |  | 
| 89 74 | 
             
            When an error or message occurs, the notification is immediately sent to Sentry. Raven can be configured to send asynchronously:
         | 
| @@ -96,15 +81,15 @@ config.async = lambda { |event| | |
| 96 81 |  | 
| 97 82 | 
             
            Using a thread to send events will be adequate for truly parallel Ruby platforms such as JRuby, though the benefit on MRI/CRuby will be limited. If the async callback raises an exception, Raven will attempt to send synchronously.
         | 
| 98 83 |  | 
| 99 | 
            -
            We recommend creating a background job, using your background job processor, that will send Sentry notifications in the background. | 
| 84 | 
            +
            Note that the naive example implementation has a major drawback - it can create an infinite number of threads. We recommend creating a background job, using your background job processor, that will send Sentry notifications in the background.
         | 
| 100 85 |  | 
| 101 86 | 
             
            ```ruby
         | 
| 102 87 | 
             
            config.async = lambda { |event| SentryJob.perform_later(event) }
         | 
| 103 88 |  | 
| 104 89 | 
             
            class SentryJob < ActiveJob::Base
         | 
| 105 90 | 
             
              queue_as :default
         | 
| 106 | 
            -
             | 
| 107 | 
            -
              # Important! Otherwise, we can get caught in an infinite loop.
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              # Important for ActiveJob! Otherwise, we can get caught in an infinite loop.
         | 
| 108 93 | 
             
              rescue_from(ActiveJob::DeserializationError) { |e| Rails.logger.error e }
         | 
| 109 94 |  | 
| 110 95 | 
             
              def perform(event)
         | 
| @@ -146,6 +131,5 @@ For more information, see [Context](https://docs.sentry.io/clients/ruby/context/ | |
| 146 131 |  | 
| 147 132 | 
             
            * [Documentation](https://docs.getsentry.com/hosted/clients/ruby/)
         | 
| 148 133 | 
             
            * [Bug Tracker](https://github.com/getsentry/raven-ruby/issues)
         | 
| 149 | 
            -
            * [ | 
| 150 | 
            -
            * [Mailing List](https://groups.google.com/group/getsentry)
         | 
| 134 | 
            +
            * [Forum](https://forum.sentry.io/)
         | 
| 151 135 | 
             
            * [IRC](irc://irc.freenode.net/sentry>)  (irc.freenode.net, #sentry)
         | 
    
        data/changelog.md
    CHANGED
    
    | @@ -1,3 +1,16 @@ | |
| 1 | 
            +
            2.6.0
         | 
| 2 | 
            +
            -----
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            * FEATURE: raven-ruby now marks itself as the "ruby" logger by default, to match raven-js behavior [@nateberkopec]
         | 
| 5 | 
            +
            * FEATURE: You may now override the default sanitization parameters [#712, @nateberkopec]
         | 
| 6 | 
            +
            * FEATURE: Breadcrumb buffers are now publicly accessible [#686, @nateberkopec]
         | 
| 7 | 
            +
            * FEATURE: We yell at you now if you're using Heroku but don't have runtime-dyno-metadata enabled [#715, @nateberkopec]
         | 
| 8 | 
            +
            * FEATURE: project_root will always be set, regardless of framework [#716, @nateberkopec]
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            * BUGFIX: Request body and message limits now match Sentry server defaults [#714, @nateberkopec]
         | 
| 11 | 
            +
            * BUGFIX: Sidekiq context now works as expected [#713, @nateberkopec]
         | 
| 12 | 
            +
            * BUGFIX: Capture exceptions in ActiveJob when not using Sidekiq adapter [#709, #671, @nateberkopec]
         | 
| 13 | 
            +
             | 
| 1 14 | 
             
            2.5.3
         | 
| 2 15 | 
             
            -----
         | 
| 3 16 |  | 
    
        data/docs/config.rst
    CHANGED
    
    | @@ -82,13 +82,13 @@ Optional settings | |
| 82 82 |  | 
| 83 83 | 
             
                .. code-block:: ruby
         | 
| 84 84 |  | 
| 85 | 
            -
                    config.excluded_exceptions  | 
| 85 | 
            +
                    config.excluded_exceptions += ['ActionController::RoutingError', 'ActiveRecord::RecordNotFound']
         | 
| 86 86 |  | 
| 87 | 
            -
                You can find the list of exceptions that are excluded by default in ``Raven::Configuration::IGNORE_DEFAULT``.  | 
| 87 | 
            +
                You can find the list of exceptions that are excluded by default in ``Raven::Configuration::IGNORE_DEFAULT``. It is suggested that you append to these defaults rather than overwrite them with ``=``.
         | 
| 88 88 |  | 
| 89 89 | 
             
            .. describe:: logger
         | 
| 90 90 |  | 
| 91 | 
            -
                The  | 
| 91 | 
            +
                The logger used by Sentry. Default is an instance of Raven::Logger.
         | 
| 92 92 |  | 
| 93 93 | 
             
                .. code-block:: ruby
         | 
| 94 94 |  | 
    
        data/docs/context.rst
    CHANGED
    
    | @@ -24,6 +24,7 @@ The following attributes are available: | |
| 24 24 | 
             
            * ``server_name``: the hostname of the server
         | 
| 25 25 | 
             
            * ``tags``: a mapping of tags describing this event
         | 
| 26 26 | 
             
            * ``extra``: a mapping of arbitrary context
         | 
| 27 | 
            +
            * ``user``: a mapping of user context
         | 
| 27 28 |  | 
| 28 29 | 
             
            Providing Request Context
         | 
| 29 30 | 
             
            -------------------------
         | 
    
        data/docs/integrations/index.rst
    CHANGED
    
    | @@ -12,6 +12,7 @@ features if you want. | |
| 12 12 | 
             
               rails
         | 
| 13 13 | 
             
               rack
         | 
| 14 14 | 
             
               puma
         | 
| 15 | 
            +
               heroku
         | 
| 15 16 |  | 
| 16 17 | 
             
            The following integrations are available:
         | 
| 17 18 |  | 
| @@ -30,7 +31,7 @@ the default integration behavior doesn't suit your projects' needs. | |
| 30 31 |  | 
| 31 32 | 
             
            To explicitly include integrations:
         | 
| 32 33 |  | 
| 33 | 
            -
            ::
         | 
| 34 | 
            +
            .. sourcecode:: ruby
         | 
| 34 35 |  | 
| 35 36 | 
             
               require 'sentry-raven-without-integrations'
         | 
| 36 37 | 
             
               Raven.inject_only(:railties, :rack, :rake)
         | 
| @@ -38,7 +39,7 @@ To explicitly include integrations: | |
| 38 39 |  | 
| 39 40 | 
             
            To blacklist integrations:
         | 
| 40 41 |  | 
| 41 | 
            -
            ::
         | 
| 42 | 
            +
            .. sourcecode:: ruby
         | 
| 42 43 |  | 
| 43 44 | 
             
               require 'sentry-raven-without-integrations'
         | 
| 44 45 | 
             
               Raven.inject_without(:sidekiq, :delayed_job)
         | 
| @@ -46,13 +47,13 @@ To blacklist integrations: | |
| 46 47 |  | 
| 47 48 | 
             
            If you're using bundler, then in your gemfile:
         | 
| 48 49 |  | 
| 49 | 
            -
            ::
         | 
| 50 | 
            +
            .. sourcecode:: ruby
         | 
| 50 51 |  | 
| 51 52 | 
             
               gem 'sentry-raven', require: 'sentry-raven-without-integrations'
         | 
| 52 53 |  | 
| 53 54 |  | 
| 54 55 | 
             
            And in some sort of initializer:
         | 
| 55 56 |  | 
| 56 | 
            -
            ::
         | 
| 57 | 
            +
            .. sourcecode:: ruby
         | 
| 57 58 |  | 
| 58 59 | 
             
               Raven.inject_without(:sidekiq)
         | 
    
        data/lib/raven/breadcrumbs.rb
    CHANGED
    
    
    
        data/lib/raven/cli.rb
    CHANGED
    
    | @@ -1,57 +1,58 @@ | |
| 1 1 | 
             
            module Raven
         | 
| 2 2 | 
             
              class CLI
         | 
| 3 | 
            -
                def self.test(dsn = nil, silent = false) # rubocop:disable all
         | 
| 4 | 
            -
                   | 
| 5 | 
            -
                    Raven.configuration.logger = ::Logger.new(nil)
         | 
| 6 | 
            -
                  else
         | 
| 7 | 
            -
                    logger = ::Logger.new(STDOUT)
         | 
| 8 | 
            -
                    logger.level = ::Logger::ERROR
         | 
| 9 | 
            -
                    logger.formatter = proc do |_severity, _datetime, _progname, msg|
         | 
| 10 | 
            -
                      "-> #{msg}\n"
         | 
| 11 | 
            -
                    end
         | 
| 3 | 
            +
                def self.test(dsn = nil, silent = false, config = nil) # rubocop:disable all
         | 
| 4 | 
            +
                  config ||= Raven.configuration
         | 
| 12 5 |  | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 6 | 
            +
                  config.logger = if silent
         | 
| 7 | 
            +
                                    ::Logger.new(nil)
         | 
| 8 | 
            +
                                  else
         | 
| 9 | 
            +
                                    logger = ::Logger.new(STDOUT)
         | 
| 10 | 
            +
                                    logger.formatter = proc do |_severity, _datetime, _progname, msg|
         | 
| 11 | 
            +
                                      "-> #{msg}\n"
         | 
| 12 | 
            +
                                    end
         | 
| 13 | 
            +
                                    logger
         | 
| 14 | 
            +
                                  end
         | 
| 15 15 |  | 
| 16 | 
            -
                   | 
| 17 | 
            -
                   | 
| 16 | 
            +
                  config.timeout = 5
         | 
| 17 | 
            +
                  config.dsn = dsn if dsn
         | 
| 18 18 |  | 
| 19 19 | 
             
                  # wipe out env settings to ensure we send the event
         | 
| 20 | 
            -
                  unless  | 
| 21 | 
            -
                    env_name =  | 
| 22 | 
            -
                     | 
| 23 | 
            -
                    Raven.configuration.current_environment = env_name
         | 
| 20 | 
            +
                  unless config.capture_allowed?
         | 
| 21 | 
            +
                    env_name = config.environments.pop || 'production'
         | 
| 22 | 
            +
                    config.current_environment = env_name
         | 
| 24 23 | 
             
                  end
         | 
| 25 24 |  | 
| 26 | 
            -
                  Raven. | 
| 27 | 
            -
             | 
| 25 | 
            +
                  instance = Raven::Instance.new(nil, config)
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  instance.logger.debug "Sending a test event:"
         | 
| 28 | 
            +
                  instance.logger.debug ""
         | 
| 28 29 |  | 
| 29 30 | 
             
                  begin
         | 
| 30 31 | 
             
                    1 / 0
         | 
| 31 32 | 
             
                  rescue ZeroDivisionError => exception
         | 
| 32 | 
            -
                    evt =  | 
| 33 | 
            +
                    evt = instance.capture_exception(exception)
         | 
| 33 34 | 
             
                  end
         | 
| 34 35 |  | 
| 35 36 | 
             
                  if evt && !(evt.is_a? Thread)
         | 
| 36 37 | 
             
                    if evt.is_a? Hash
         | 
| 37 | 
            -
                       | 
| 38 | 
            +
                      instance.logger.debug "-> event ID: #{evt[:event_id]}"
         | 
| 38 39 | 
             
                    else
         | 
| 39 | 
            -
                       | 
| 40 | 
            +
                      instance.logger.debug "-> event ID: #{evt.id}"
         | 
| 40 41 | 
             
                    end
         | 
| 41 42 | 
             
                  elsif evt # async configuration
         | 
| 42 43 | 
             
                    if evt.value.is_a? Hash
         | 
| 43 | 
            -
                       | 
| 44 | 
            +
                      instance.logger.debug "-> event ID: #{evt.value[:event_id]}"
         | 
| 44 45 | 
             
                    else
         | 
| 45 | 
            -
                       | 
| 46 | 
            +
                      instance.logger.debug "-> event ID: #{evt.value.id}"
         | 
| 46 47 | 
             
                    end
         | 
| 47 48 | 
             
                  else
         | 
| 48 | 
            -
                     | 
| 49 | 
            -
                     | 
| 49 | 
            +
                    instance.logger.debug ""
         | 
| 50 | 
            +
                    instance.logger.debug "An error occurred while attempting to send the event."
         | 
| 50 51 | 
             
                    exit 1
         | 
| 51 52 | 
             
                  end
         | 
| 52 53 |  | 
| 53 | 
            -
                   | 
| 54 | 
            -
                   | 
| 54 | 
            +
                  instance.logger.debug ""
         | 
| 55 | 
            +
                  instance.logger.debug "Done!"
         | 
| 55 56 | 
             
                  true
         | 
| 56 57 | 
             
                end
         | 
| 57 58 | 
             
              end
         | 
    
        data/lib/raven/configuration.rb
    CHANGED
    
    | @@ -99,6 +99,10 @@ module Raven | |
| 99 99 | 
             
                # a hash key, will be censored and not sent to Sentry.
         | 
| 100 100 | 
             
                attr_accessor :sanitize_fields
         | 
| 101 101 |  | 
| 102 | 
            +
                # If you're sure you want to override the default sanitization values, you can
         | 
| 103 | 
            +
                # add to them to an array of Strings here, e.g. %w(authorization password)
         | 
| 104 | 
            +
                attr_accessor :sanitize_fields_excluded
         | 
| 105 | 
            +
             | 
| 102 106 | 
             
                # Sanitize additional HTTP headers - only Authorization is removed by default.
         | 
| 103 107 | 
             
                attr_accessor :sanitize_http_headers
         | 
| 104 108 |  | 
| @@ -185,12 +189,14 @@ module Raven | |
| 185 189 | 
             
                  self.logger = ::Raven::Logger.new(STDOUT)
         | 
| 186 190 | 
             
                  self.open_timeout = 1
         | 
| 187 191 | 
             
                  self.processors = DEFAULT_PROCESSORS.dup
         | 
| 192 | 
            +
                  self.project_root = detect_project_root
         | 
| 188 193 | 
             
                  self.proxy = nil
         | 
| 189 194 | 
             
                  self.rails_activesupport_breadcrumbs = false
         | 
| 190 195 | 
             
                  self.rails_report_rescued_exceptions = true
         | 
| 191 196 | 
             
                  self.release = detect_release
         | 
| 192 197 | 
             
                  self.sanitize_credit_cards = true
         | 
| 193 198 | 
             
                  self.sanitize_fields = []
         | 
| 199 | 
            +
                  self.sanitize_fields_excluded = []
         | 
| 194 200 | 
             
                  self.sanitize_http_headers = []
         | 
| 195 201 | 
             
                  self.send_modules = true
         | 
| 196 202 | 
             
                  self.server = ENV['SENTRY_DSN'] if ENV['SENTRY_DSN']
         | 
| @@ -286,28 +292,45 @@ module Raven | |
| 286 292 | 
             
                  detect_release_from_git ||
         | 
| 287 293 | 
             
                    detect_release_from_capistrano ||
         | 
| 288 294 | 
             
                    detect_release_from_heroku
         | 
| 295 | 
            +
                rescue => ex
         | 
| 296 | 
            +
                  logger.error "Error detecting release: #{ex.message}"
         | 
| 297 | 
            +
                end
         | 
| 298 | 
            +
             | 
| 299 | 
            +
                def detect_project_root
         | 
| 300 | 
            +
                  if defined? Rails.root # we are in a Rails application
         | 
| 301 | 
            +
                    Rails.root.to_s
         | 
| 302 | 
            +
                  else
         | 
| 303 | 
            +
                    Dir.pwd
         | 
| 304 | 
            +
                  end
         | 
| 289 305 | 
             
                end
         | 
| 290 306 |  | 
| 291 307 | 
             
                private
         | 
| 292 308 |  | 
| 293 309 | 
             
                def detect_release_from_heroku
         | 
| 294 | 
            -
                   | 
| 295 | 
            -
                  return unless  | 
| 296 | 
            -
             | 
| 297 | 
            -
                   | 
| 298 | 
            -
             | 
| 299 | 
            -
             | 
| 300 | 
            -
             | 
| 301 | 
            -
                   | 
| 302 | 
            -
             | 
| 303 | 
            -
             | 
| 310 | 
            +
                  return unless running_on_heroku?
         | 
| 311 | 
            +
                  logger.warn(heroku_dyno_metadata_message) && return unless ENV['HEROKU_SLUG_COMMIT']
         | 
| 312 | 
            +
             | 
| 313 | 
            +
                  ENV['HEROKU_SLUG_COMMIT']
         | 
| 314 | 
            +
                end
         | 
| 315 | 
            +
             | 
| 316 | 
            +
                def running_on_heroku?
         | 
| 317 | 
            +
                  File.directory?("/etc/heroku")
         | 
| 318 | 
            +
                end
         | 
| 319 | 
            +
             | 
| 320 | 
            +
                def heroku_dyno_metadata_message
         | 
| 321 | 
            +
                  "You are running on Heroku but haven't enabled Dyno Metadata. For Sentry's"\
         | 
| 322 | 
            +
                  "release detection to work correctly, please run `heroku labs:enable runtime-dyno-metadata`"
         | 
| 304 323 | 
             
                end
         | 
| 305 324 |  | 
| 306 325 | 
             
                def detect_release_from_capistrano
         | 
| 307 | 
            -
                   | 
| 326 | 
            +
                  revision_file = File.join(project_root, 'REVISION')
         | 
| 327 | 
            +
                  revision_log = File.join(project_root, '..', 'revisions.log')
         | 
| 308 328 |  | 
| 309 | 
            -
                   | 
| 310 | 
            -
             | 
| 329 | 
            +
                  if File.exist?(revision_file)
         | 
| 330 | 
            +
                    File.read(revision_file).strip
         | 
| 331 | 
            +
                  elsif File.exist?(revision_log)
         | 
| 332 | 
            +
                    File.open(revision_log).to_a.last.strip.sub(/.*as release ([0-9]+).*/, '\1')
         | 
| 333 | 
            +
                  end
         | 
| 311 334 | 
             
                end
         | 
| 312 335 |  | 
| 313 336 | 
             
                def detect_release_from_git
         | 
    
        data/lib/raven/event.rb
    CHANGED
    
    | @@ -19,6 +19,9 @@ module Raven | |
| 19 19 | 
             
                }.freeze
         | 
| 20 20 |  | 
| 21 21 | 
             
                BACKTRACE_RE = /^(.+?):(\d+)(?::in `(.+?)')?$/
         | 
| 22 | 
            +
                # See Sentry server default limits at
         | 
| 23 | 
            +
                # https://github.com/getsentry/sentry/blob/master/src/sentry/conf/server.py
         | 
| 24 | 
            +
                MAX_MESSAGE_SIZE_IN_BYTES = 1024 * 8
         | 
| 22 25 |  | 
| 23 26 | 
             
                PLATFORM = "ruby".freeze
         | 
| 24 27 | 
             
                SDK = { "name" => "raven-ruby", "version" => Raven::VERSION }.freeze
         | 
| @@ -38,7 +41,7 @@ module Raven | |
| 38 41 | 
             
                  @timestamp     = Time.now.utc
         | 
| 39 42 | 
             
                  @time_spent    = nil
         | 
| 40 43 | 
             
                  @level         = :error
         | 
| 41 | 
            -
                  @logger        = ''
         | 
| 44 | 
            +
                  @logger        = 'ruby'
         | 
| 42 45 | 
             
                  @culprit       = nil
         | 
| 43 46 | 
             
                  @server_name   = @configuration.server_name
         | 
| 44 47 | 
             
                  @release       = @configuration.release
         | 
| @@ -106,7 +109,7 @@ module Raven | |
| 106 109 |  | 
| 107 110 | 
             
                    new(options) do |evt|
         | 
| 108 111 | 
             
                      evt.configuration = configuration
         | 
| 109 | 
            -
                      evt.message = "#{exc.class}: #{exc.message}".byteslice(0... | 
| 112 | 
            +
                      evt.message = "#{exc.class}: #{exc.message}".byteslice(0...MAX_MESSAGE_SIZE_IN_BYTES) # Messages limited to 10kb
         | 
| 110 113 | 
             
                      evt.level = options[:level] || :error
         | 
| 111 114 |  | 
| 112 115 | 
             
                      add_exception_interface(evt, exc)
         | 
| @@ -116,7 +119,7 @@ module Raven | |
| 116 119 | 
             
                  end
         | 
| 117 120 |  | 
| 118 121 | 
             
                  def from_message(message, options = {})
         | 
| 119 | 
            -
                    message = message.byteslice(0... | 
| 122 | 
            +
                    message = message.byteslice(0...MAX_MESSAGE_SIZE_IN_BYTES)
         | 
| 120 123 | 
             
                    configuration = options[:configuration] || Raven.configuration
         | 
| 121 124 |  | 
| 122 125 | 
             
                    new(options) do |evt|
         | 
| @@ -80,11 +80,13 @@ module Raven | |
| 80 80 |  | 
| 81 81 | 
             
                private
         | 
| 82 82 |  | 
| 83 | 
            +
                # See Sentry server default limits at
         | 
| 84 | 
            +
                # https://github.com/getsentry/sentry/blob/master/src/sentry/conf/server.py
         | 
| 83 85 | 
             
                def read_data_from(request)
         | 
| 84 86 | 
             
                  if request.form_data?
         | 
| 85 87 | 
             
                    request.POST
         | 
| 86 88 | 
             
                  elsif request.body # JSON requests, etc
         | 
| 87 | 
            -
                    data = request.body.read( | 
| 89 | 
            +
                    data = request.body.read(4096 * 4) # Sentry server limit
         | 
| 88 90 | 
             
                    request.body.rewind
         | 
| 89 91 | 
             
                    data
         | 
| 90 92 | 
             
                  end
         | 
| @@ -37,11 +37,6 @@ module Raven | |
| 37 37 | 
             
                end
         | 
| 38 38 |  | 
| 39 39 | 
             
                config.after_initialize do
         | 
| 40 | 
            -
                  Raven.configure do |config|
         | 
| 41 | 
            -
                    config.project_root ||= ::Rails.root
         | 
| 42 | 
            -
                    config.release ||= config.detect_release # if project_root has changed, need to re-check
         | 
| 43 | 
            -
                  end
         | 
| 44 | 
            -
             | 
| 45 40 | 
             
                  if Raven.configuration.rails_activesupport_breadcrumbs
         | 
| 46 41 | 
             
                    require 'raven/breadcrumbs/activesupport'
         | 
| 47 42 | 
             
                    Raven::ActiveSupportBreadcrumbs.inject
         | 
| @@ -63,6 +58,12 @@ module Raven | |
| 63 58 | 
             
                  end
         | 
| 64 59 | 
             
                end
         | 
| 65 60 |  | 
| 61 | 
            +
                initializer 'raven.active_job' do
         | 
| 62 | 
            +
                  ActiveSupport.on_load :active_job do
         | 
| 63 | 
            +
                    require 'raven/integrations/rails/active_job'
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 66 67 | 
             
                rake_tasks do
         | 
| 67 68 | 
             
                  require 'raven/integrations/tasks'
         | 
| 68 69 | 
             
                end
         | 
| @@ -1,31 +1,53 @@ | |
| 1 1 | 
             
            module Raven
         | 
| 2 2 | 
             
              class Rails
         | 
| 3 | 
            -
                module  | 
| 3 | 
            +
                module ActiveJobExtensions
         | 
| 4 | 
            +
                  ALREADY_SUPPORTED_SENTRY_ADAPTERS = %w(
         | 
| 5 | 
            +
                    ActiveJob::QueueAdapters::SidekiqAdapter
         | 
| 6 | 
            +
                    ActiveJob::QueueAdapters::DelayedJobAdapter
         | 
| 7 | 
            +
                  ).freeze
         | 
| 8 | 
            +
             | 
| 4 9 | 
             
                  def self.included(base)
         | 
| 5 10 | 
             
                    base.class_eval do
         | 
| 6 | 
            -
                       | 
| 7 | 
            -
                         | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
                            :active_job => self.class.name,
         | 
| 12 | 
            -
                            :arguments => arguments,
         | 
| 13 | 
            -
                            :scheduled_at => scheduled_at,
         | 
| 14 | 
            -
                            :job_id => job_id,
         | 
| 15 | 
            -
                            :locale => locale
         | 
| 16 | 
            -
                          }
         | 
| 11 | 
            +
                      around_perform do |job, block|
         | 
| 12 | 
            +
                        capture_and_reraise_with_sentry(job, block)
         | 
| 13 | 
            +
                      end
         | 
| 14 | 
            +
                    end
         | 
| 15 | 
            +
                  end
         | 
| 17 16 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 17 | 
            +
                  def capture_and_reraise_with_sentry(job, block)
         | 
| 18 | 
            +
                    block.call
         | 
| 19 | 
            +
                  rescue Exception => exception # rubocop:disable Lint/RescueException
         | 
| 20 | 
            +
                    return if already_supported_by_specific_integration?(job)
         | 
| 21 | 
            +
                    Raven.capture_exception(exception, :extra => raven_context(job))
         | 
| 22 | 
            +
                    raise exception
         | 
| 23 | 
            +
                  ensure
         | 
| 24 | 
            +
                    Context.clear!
         | 
| 25 | 
            +
                    BreadcrumbBuffer.clear!
         | 
| 26 | 
            +
                  end
         | 
| 22 27 |  | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 28 | 
            +
                  def already_supported_by_specific_integration?(job)
         | 
| 29 | 
            +
                    ALREADY_SUPPORTED_SENTRY_ADAPTERS.include?(job.class.queue_adapter.to_s)
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  def raven_context(job)
         | 
| 33 | 
            +
                    ctx = {
         | 
| 34 | 
            +
                      :active_job => job.class.name,
         | 
| 35 | 
            +
                      :arguments => job.arguments,
         | 
| 36 | 
            +
                      :scheduled_at => job.scheduled_at,
         | 
| 37 | 
            +
                      :job_id => job.job_id,
         | 
| 38 | 
            +
                      :locale => job.locale
         | 
| 39 | 
            +
                    }
         | 
| 40 | 
            +
                    # Add provider_job_id details if Rails 5
         | 
| 41 | 
            +
                    if job.respond_to?(:provider_job_id)
         | 
| 42 | 
            +
                      ctx[:provider_job_id] = job.provider_job_id
         | 
| 27 43 | 
             
                    end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                    ctx
         | 
| 28 46 | 
             
                  end
         | 
| 29 47 | 
             
                end
         | 
| 30 48 | 
             
              end
         | 
| 31 49 | 
             
            end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            class ActiveJob::Base
         | 
| 52 | 
            +
              include Raven::Rails::ActiveJobExtensions
         | 
| 53 | 
            +
            end
         | 
| @@ -5,7 +5,6 @@ module Raven | |
| 5 5 | 
             
              class SidekiqCleanupMiddleware
         | 
| 6 6 | 
             
                def call(_worker, _job, _queue)
         | 
| 7 7 | 
             
                  yield
         | 
| 8 | 
            -
                ensure
         | 
| 9 8 | 
             
                  Context.clear!
         | 
| 10 9 | 
             
                  BreadcrumbBuffer.clear!
         | 
| 11 10 | 
             
                end
         | 
| @@ -22,6 +21,8 @@ module Raven | |
| 22 21 | 
             
                    :extra => { :sidekiq => context },
         | 
| 23 22 | 
             
                    :culprit => culprit_from_context(context)
         | 
| 24 23 | 
             
                  )
         | 
| 24 | 
            +
                  Context.clear!
         | 
| 25 | 
            +
                  BreadcrumbBuffer.clear!
         | 
| 25 26 | 
             
                end
         | 
| 26 27 |  | 
| 27 28 | 
             
                private
         | 
| @@ -5,13 +5,16 @@ module Raven | |
| 5 5 | 
             
              class Processor::SanitizeData < Processor
         | 
| 6 6 | 
             
                DEFAULT_FIELDS = %w(authorization password passwd secret ssn social(.*)?sec).freeze
         | 
| 7 7 | 
             
                CREDIT_CARD_RE = /^(?:\d[ -]*?){13,16}$/
         | 
| 8 | 
            +
                QUERY_STRING = ['query_string', :query_string].freeze
         | 
| 9 | 
            +
                JSON_STARTS_WITH = ["[", "{"].freeze
         | 
| 8 10 |  | 
| 9 | 
            -
                attr_accessor :sanitize_fields, :sanitize_credit_cards
         | 
| 11 | 
            +
                attr_accessor :sanitize_fields, :sanitize_credit_cards, :sanitize_fields_excluded
         | 
| 10 12 |  | 
| 11 13 | 
             
                def initialize(client)
         | 
| 12 14 | 
             
                  super
         | 
| 13 15 | 
             
                  self.sanitize_fields = client.configuration.sanitize_fields
         | 
| 14 16 | 
             
                  self.sanitize_credit_cards = client.configuration.sanitize_credit_cards
         | 
| 17 | 
            +
                  self.sanitize_fields_excluded = client.configuration.sanitize_fields_excluded
         | 
| 15 18 | 
             
                end
         | 
| 16 19 |  | 
| 17 20 | 
             
                def process(value, key = nil)
         | 
| @@ -28,7 +31,7 @@ module Raven | |
| 28 31 | 
             
                      process(json).to_json
         | 
| 29 32 | 
             
                    elsif matches_regexes?(key, value)
         | 
| 30 33 | 
             
                      STRING_MASK
         | 
| 31 | 
            -
                    elsif key | 
| 34 | 
            +
                    elsif QUERY_STRING.include?(key)
         | 
| 32 35 | 
             
                      sanitize_query_string(value)
         | 
| 33 36 | 
             
                    else
         | 
| 34 37 | 
             
                      value
         | 
| @@ -59,7 +62,10 @@ module Raven | |
| 59 62 | 
             
                end
         | 
| 60 63 |  | 
| 61 64 | 
             
                def fields_re
         | 
| 62 | 
            -
                  @fields_re  | 
| 65 | 
            +
                  return @fields_re if @fields_re
         | 
| 66 | 
            +
                  fields = DEFAULT_FIELDS | sanitize_fields
         | 
| 67 | 
            +
                  fields -= sanitize_fields_excluded
         | 
| 68 | 
            +
                  @fields_re = /#{fields.map do |f|
         | 
| 63 69 | 
             
                    use_boundary?(f) ? "\\b#{f}\\b" : f
         | 
| 64 70 | 
             
                  end.join("|")}/i
         | 
| 65 71 | 
             
                end
         | 
| @@ -73,7 +79,7 @@ module Raven | |
| 73 79 | 
             
                end
         | 
| 74 80 |  | 
| 75 81 | 
             
                def parse_json_or_nil(string)
         | 
| 76 | 
            -
                  return unless string.start_with?( | 
| 82 | 
            +
                  return unless string.start_with?(*JSON_STARTS_WITH)
         | 
| 77 83 | 
             
                  JSON.parse(string)
         | 
| 78 84 | 
             
                rescue JSON::ParserError, NoMethodError
         | 
| 79 85 | 
             
                  nil
         | 
| @@ -12,7 +12,7 @@ module Raven | |
| 12 12 | 
             
                      this_value = hash[current_key]
         | 
| 13 13 |  | 
| 14 14 | 
             
                      hash[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
         | 
| 15 | 
            -
                         | 
| 15 | 
            +
                        deep_merge(this_value, other_value, &block)
         | 
| 16 16 | 
             
                      else
         | 
| 17 17 | 
             
                        if block_given? && key?(current_key)
         | 
| 18 18 | 
             
                          block.call(current_key, this_value, other_value)
         | 
    
        data/lib/raven/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sentry-raven
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.6.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Sentry Team
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017- | 
| 11 | 
            +
            date: 2017-07-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: faraday
         | 
| @@ -56,6 +56,7 @@ files: | |
| 56 56 | 
             
            - docs/context.rst
         | 
| 57 57 | 
             
            - docs/index.rst
         | 
| 58 58 | 
             
            - docs/install.rst
         | 
| 59 | 
            +
            - docs/integrations/heroku.rst
         | 
| 59 60 | 
             
            - docs/integrations/index.rst
         | 
| 60 61 | 
             
            - docs/integrations/puma.rst
         | 
| 61 62 | 
             
            - docs/integrations/rack.rst
         |