airbrake-ruby 5.0.0.rc.2-java → 5.0.1-java
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/lib/airbrake-ruby/backtrace.rb +6 -5
- data/lib/airbrake-ruby/config.rb +8 -36
- data/lib/airbrake-ruby/config/processor.rb +7 -3
- data/lib/airbrake-ruby/config/validator.rb +2 -0
- data/lib/airbrake-ruby/file_cache.rb +1 -1
- data/lib/airbrake-ruby/filter_chain.rb +1 -0
- data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -2
- data/lib/airbrake-ruby/filters/git_repository_filter.rb +3 -0
- data/lib/airbrake-ruby/filters/git_revision_filter.rb +2 -0
- data/lib/airbrake-ruby/filters/keys_filter.rb +21 -13
- data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/sql_filter.rb +4 -4
- data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/thread_filter.rb +2 -0
- data/lib/airbrake-ruby/ignorable.rb +1 -0
- data/lib/airbrake-ruby/notice_notifier.rb +1 -0
- data/lib/airbrake-ruby/performance_breakdown.rb +1 -6
- data/lib/airbrake-ruby/performance_notifier.rb +1 -14
- data/lib/airbrake-ruby/promise.rb +1 -0
- data/lib/airbrake-ruby/query.rb +1 -6
- data/lib/airbrake-ruby/queue.rb +1 -8
- data/lib/airbrake-ruby/remote_settings.rb +7 -5
- data/lib/airbrake-ruby/remote_settings/settings_data.rb +15 -10
- data/lib/airbrake-ruby/request.rb +1 -8
- data/lib/airbrake-ruby/stat.rb +1 -12
- data/lib/airbrake-ruby/sync_sender.rb +1 -0
- data/lib/airbrake-ruby/tdigest.rb +2 -0
- data/lib/airbrake-ruby/thread_pool.rb +1 -0
- data/lib/airbrake-ruby/truncator.rb +8 -2
- data/lib/airbrake-ruby/version.rb +2 -2
- data/spec/backtrace_spec.rb +26 -26
- data/spec/code_hunk_spec.rb +2 -2
- data/spec/config/processor_spec.rb +5 -19
- data/spec/config_spec.rb +4 -29
- data/spec/filters/gem_root_filter_spec.rb +4 -4
- data/spec/filters/keys_allowlist_spec.rb +1 -0
- data/spec/filters/keys_blocklist_spec.rb +10 -0
- data/spec/filters/root_directory_filter_spec.rb +4 -4
- data/spec/filters/sql_filter_spec.rb +2 -2
- data/spec/notice_notifier/options_spec.rb +2 -2
- data/spec/notice_notifier_spec.rb +2 -2
- data/spec/notice_spec.rb +1 -1
- data/spec/performance_breakdown_spec.rb +0 -12
- data/spec/performance_notifier_spec.rb +0 -25
- data/spec/query_spec.rb +1 -11
- data/spec/queue_spec.rb +1 -13
- data/spec/remote_settings/settings_data_spec.rb +64 -13
- data/spec/remote_settings_spec.rb +14 -14
- data/spec/request_spec.rb +1 -13
- data/spec/spec_helper.rb +4 -4
- data/spec/stat_spec.rb +0 -9
- metadata +5 -5
| @@ -12,16 +12,13 @@ module Airbrake | |
| 12 12 | 
             
                include Stashable
         | 
| 13 13 | 
             
                include Mergeable
         | 
| 14 14 |  | 
| 15 | 
            -
                attr_accessor :method, :route, :response_type, :groups, : | 
| 16 | 
            -
                              :end_time, :timing, :time
         | 
| 15 | 
            +
                attr_accessor :method, :route, :response_type, :groups, :timing, :time
         | 
| 17 16 |  | 
| 18 17 | 
             
                def initialize(
         | 
| 19 18 | 
             
                  method:,
         | 
| 20 19 | 
             
                  route:,
         | 
| 21 20 | 
             
                  response_type:,
         | 
| 22 21 | 
             
                  groups:,
         | 
| 23 | 
            -
                  start_time: Time.now,
         | 
| 24 | 
            -
                  end_time: start_time + 1,
         | 
| 25 22 | 
             
                  timing: nil,
         | 
| 26 23 | 
             
                  time: Time.now
         | 
| 27 24 | 
             
                )
         | 
| @@ -30,8 +27,6 @@ module Airbrake | |
| 30 27 | 
             
                  @route = route
         | 
| 31 28 | 
             
                  @response_type = response_type
         | 
| 32 29 | 
             
                  @groups = groups
         | 
| 33 | 
            -
                  @start_time = start_time
         | 
| 34 | 
            -
                  @end_time = end_time
         | 
| 35 30 | 
             
                  @timing = timing
         | 
| 36 31 | 
             
                  @time = time
         | 
| 37 32 | 
             
                end
         | 
| @@ -104,7 +104,7 @@ module Airbrake | |
| 104 104 | 
             
                    @payload[resource] = { total: Airbrake::Stat.new }
         | 
| 105 105 | 
             
                  end
         | 
| 106 106 |  | 
| 107 | 
            -
                   | 
| 107 | 
            +
                  @payload[resource][:total].increment_ms(resource.timing)
         | 
| 108 108 |  | 
| 109 109 | 
             
                  resource.groups.each do |name, ms|
         | 
| 110 110 | 
             
                    @payload[resource][name] ||= Airbrake::Stat.new
         | 
| @@ -112,19 +112,6 @@ module Airbrake | |
| 112 112 | 
             
                  end
         | 
| 113 113 | 
             
                end
         | 
| 114 114 |  | 
| 115 | 
            -
                def update_total(resource, total)
         | 
| 116 | 
            -
                  if resource.timing
         | 
| 117 | 
            -
                    total.increment_ms(resource.timing)
         | 
| 118 | 
            -
                  else
         | 
| 119 | 
            -
                    loc = caller_locations(6..6).first
         | 
| 120 | 
            -
                    Kernel.warn(
         | 
| 121 | 
            -
                      "#{loc.path}:#{loc.lineno}: warning: :start_time and :end_time are " \
         | 
| 122 | 
            -
                      "deprecated. Use :timing & :time instead",
         | 
| 123 | 
            -
                    )
         | 
| 124 | 
            -
                    total.increment(resource.start_time, resource.end_time)
         | 
| 125 | 
            -
                  end
         | 
| 126 | 
            -
                end
         | 
| 127 | 
            -
             | 
| 128 115 | 
             
                def check_configuration(resource)
         | 
| 129 116 | 
             
                  promise = @config.check_configuration
         | 
| 130 117 | 
             
                  return promise if promise.rejected?
         | 
    
        data/lib/airbrake-ruby/query.rb
    CHANGED
    
    | @@ -12,8 +12,7 @@ module Airbrake | |
| 12 12 | 
             
                include Mergeable
         | 
| 13 13 | 
             
                include Grouppable
         | 
| 14 14 |  | 
| 15 | 
            -
                attr_accessor :method, :route, :query, :func, :file, :line, : | 
| 16 | 
            -
                              :end_time, :timing, :time
         | 
| 15 | 
            +
                attr_accessor :method, :route, :query, :func, :file, :line, :timing, :time
         | 
| 17 16 |  | 
| 18 17 | 
             
                def initialize(
         | 
| 19 18 | 
             
                  method:,
         | 
| @@ -22,8 +21,6 @@ module Airbrake | |
| 22 21 | 
             
                  func: nil,
         | 
| 23 22 | 
             
                  file: nil,
         | 
| 24 23 | 
             
                  line: nil,
         | 
| 25 | 
            -
                  start_time: Time.now,
         | 
| 26 | 
            -
                  end_time: start_time + 1,
         | 
| 27 24 | 
             
                  timing: nil,
         | 
| 28 25 | 
             
                  time: Time.now
         | 
| 29 26 | 
             
                )
         | 
| @@ -34,8 +31,6 @@ module Airbrake | |
| 34 31 | 
             
                  @func = func
         | 
| 35 32 | 
             
                  @file = file
         | 
| 36 33 | 
             
                  @line = line
         | 
| 37 | 
            -
                  @start_time = start_time
         | 
| 38 | 
            -
                  @end_time = end_time
         | 
| 39 34 | 
             
                  @timing = timing
         | 
| 40 35 | 
             
                  @time = time
         | 
| 41 36 | 
             
                end
         | 
    
        data/lib/airbrake-ruby/queue.rb
    CHANGED
    
    | @@ -4,21 +4,17 @@ module Airbrake | |
| 4 4 | 
             
              # @see Airbrake.notify_queue
         | 
| 5 5 | 
             
              # @api public
         | 
| 6 6 | 
             
              # @since v4.9.0
         | 
| 7 | 
            -
              # rubocop:disable Metrics/ParameterLists
         | 
| 8 7 | 
             
              class Queue
         | 
| 9 8 | 
             
                include HashKeyable
         | 
| 10 9 | 
             
                include Ignorable
         | 
| 11 10 | 
             
                include Stashable
         | 
| 12 11 |  | 
| 13 | 
            -
                attr_accessor :queue, :error_count, :groups, : | 
| 14 | 
            -
                              :timing, :time
         | 
| 12 | 
            +
                attr_accessor :queue, :error_count, :groups, :timing, :time
         | 
| 15 13 |  | 
| 16 14 | 
             
                def initialize(
         | 
| 17 15 | 
             
                  queue:,
         | 
| 18 16 | 
             
                  error_count:,
         | 
| 19 17 | 
             
                  groups: {},
         | 
| 20 | 
            -
                  start_time: Time.now,
         | 
| 21 | 
            -
                  end_time: start_time + 1,
         | 
| 22 18 | 
             
                  timing: nil,
         | 
| 23 19 | 
             
                  time: Time.now
         | 
| 24 20 | 
             
                )
         | 
| @@ -26,8 +22,6 @@ module Airbrake | |
| 26 22 | 
             
                  @queue = queue
         | 
| 27 23 | 
             
                  @error_count = error_count
         | 
| 28 24 | 
             
                  @groups = groups
         | 
| 29 | 
            -
                  @start_time = start_time
         | 
| 30 | 
            -
                  @end_time = end_time
         | 
| 31 25 | 
             
                  @timing = timing
         | 
| 32 26 | 
             
                  @time = time
         | 
| 33 27 | 
             
                end
         | 
| @@ -68,5 +62,4 @@ module Airbrake | |
| 68 62 | 
             
                  ''
         | 
| 69 63 | 
             
                end
         | 
| 70 64 | 
             
              end
         | 
| 71 | 
            -
              # rubocop:enable Metrics/ParameterLists
         | 
| 72 65 | 
             
            end
         | 
| @@ -13,7 +13,7 @@ module Airbrake | |
| 13 13 | 
             
              #
         | 
| 14 14 | 
             
              # When {#stop_polling} is called, the current config will be dumped to disk.
         | 
| 15 15 | 
             
              #
         | 
| 16 | 
            -
              # @since  | 
| 16 | 
            +
              # @since 5.0.0
         | 
| 17 17 | 
             
              # @api private
         | 
| 18 18 | 
             
              class RemoteSettings
         | 
| 19 19 | 
             
                include Airbrake::Loggable
         | 
| @@ -36,18 +36,20 @@ module Airbrake | |
| 36 36 | 
             
                # Polls remote config of the given project.
         | 
| 37 37 | 
             
                #
         | 
| 38 38 | 
             
                # @param [Integer] project_id
         | 
| 39 | 
            +
                # @param [String] host
         | 
| 39 40 | 
             
                # @yield [data]
         | 
| 40 41 | 
             
                # @yieldparam data [Airbrake::RemoteSettings::SettingsData]
         | 
| 41 42 | 
             
                # @return [Airbrake::RemoteSettings]
         | 
| 42 | 
            -
                def self.poll(project_id, &block)
         | 
| 43 | 
            -
                  new(project_id, &block).poll
         | 
| 43 | 
            +
                def self.poll(project_id, host, &block)
         | 
| 44 | 
            +
                  new(project_id, host, &block).poll
         | 
| 44 45 | 
             
                end
         | 
| 45 46 |  | 
| 46 47 | 
             
                # @param [Integer] project_id
         | 
| 47 48 | 
             
                # @yield [data]
         | 
| 48 49 | 
             
                # @yieldparam data [Airbrake::RemoteSettings::SettingsData]
         | 
| 49 | 
            -
                def initialize(project_id, &block)
         | 
| 50 | 
            +
                def initialize(project_id, host, &block)
         | 
| 50 51 | 
             
                  @data = SettingsData.new(project_id, {})
         | 
| 52 | 
            +
                  @host = host
         | 
| 51 53 | 
             
                  @block = block
         | 
| 52 54 | 
             
                  @poll = nil
         | 
| 53 55 | 
             
                end
         | 
| @@ -118,7 +120,7 @@ module Airbrake | |
| 118 120 | 
             
                end
         | 
| 119 121 |  | 
| 120 122 | 
             
                def build_config_uri
         | 
| 121 | 
            -
                  uri = URI(@data.config_route)
         | 
| 123 | 
            +
                  uri = URI(@data.config_route(@host))
         | 
| 122 124 | 
             
                  uri.query = QUERY_PARAMS
         | 
| 123 125 | 
             
                  uri
         | 
| 124 126 | 
             
                end
         | 
| @@ -11,7 +11,7 @@ module Airbrake | |
| 11 11 | 
             
                #
         | 
| 12 12 | 
             
                #   settings_data.interval #=> 600
         | 
| 13 13 | 
             
                #
         | 
| 14 | 
            -
                # @since  | 
| 14 | 
            +
                # @since 5.0.0
         | 
| 15 15 | 
             
                # @api private
         | 
| 16 16 | 
             
                class SettingsData
         | 
| 17 17 | 
             
                  # @return [Integer] how frequently we should poll the config API
         | 
| @@ -20,16 +20,15 @@ module Airbrake | |
| 20 20 | 
             
                  # @return [String] API version of the S3 API to poll
         | 
| 21 21 | 
             
                  API_VER = '2020-06-18'.freeze
         | 
| 22 22 |  | 
| 23 | 
            -
                  # @return [String] what  | 
| 23 | 
            +
                  # @return [String] what path to poll
         | 
| 24 24 | 
             
                  CONFIG_ROUTE_PATTERN =
         | 
| 25 | 
            -
                     | 
| 26 | 
            -
                    "#{API_VER}/config/%<project_id>s/config.json".freeze
         | 
| 25 | 
            +
                    "%<host>s/#{API_VER}/config/%<project_id>s/config.json".freeze
         | 
| 27 26 |  | 
| 28 27 | 
             
                  # @return [Hash{Symbol=>String}] the hash of all supported settings where
         | 
| 29 28 | 
             
                  #   the value is the name of the setting returned by the API
         | 
| 30 29 | 
             
                  SETTINGS = {
         | 
| 31 | 
            -
                    errors: 'errors',
         | 
| 32 | 
            -
                    apm: 'apm',
         | 
| 30 | 
            +
                    errors: 'errors'.freeze,
         | 
| 31 | 
            +
                    apm: 'apm'.freeze,
         | 
| 33 32 | 
             
                  }.freeze
         | 
| 34 33 |  | 
| 35 34 | 
             
                  # @param [Integer] project_id
         | 
| @@ -56,17 +55,23 @@ module Airbrake | |
| 56 55 | 
             
                    @data['poll_sec'] > 0 ? @data['poll_sec'] : DEFAULT_INTERVAL
         | 
| 57 56 | 
             
                  end
         | 
| 58 57 |  | 
| 58 | 
            +
                  # @param [String] remote_config_host
         | 
| 59 59 | 
             
                  # @return [String] where the config is stored on S3.
         | 
| 60 | 
            -
                  def config_route
         | 
| 61 | 
            -
                    if  | 
| 60 | 
            +
                  def config_route(remote_config_host)
         | 
| 61 | 
            +
                    if @data.key?('config_route') &&
         | 
| 62 | 
            +
                       @data['config_route'] && !@data['config_route'].empty?
         | 
| 62 63 | 
             
                      return format(
         | 
| 63 64 | 
             
                        CONFIG_ROUTE_PATTERN,
         | 
| 64 | 
            -
                         | 
| 65 | 
            +
                        host: @data['config_route'].chomp('/'),
         | 
| 65 66 | 
             
                        project_id: @project_id,
         | 
| 66 67 | 
             
                      )
         | 
| 67 68 | 
             
                    end
         | 
| 68 69 |  | 
| 69 | 
            -
                     | 
| 70 | 
            +
                    format(
         | 
| 71 | 
            +
                      CONFIG_ROUTE_PATTERN,
         | 
| 72 | 
            +
                      host: remote_config_host.chomp('/'),
         | 
| 73 | 
            +
                      project_id: @project_id,
         | 
| 74 | 
            +
                    )
         | 
| 70 75 | 
             
                  end
         | 
| 71 76 |  | 
| 72 77 | 
             
                  # @return [Boolean] whether error notifications are enabled
         | 
| @@ -4,7 +4,6 @@ module Airbrake | |
| 4 4 | 
             
              # @see Airbrake.notify_request
         | 
| 5 5 | 
             
              # @api public
         | 
| 6 6 | 
             
              # @since v3.2.0
         | 
| 7 | 
            -
              # rubocop:disable Metrics/ParameterLists
         | 
| 8 7 | 
             
              class Request
         | 
| 9 8 | 
             
                include HashKeyable
         | 
| 10 9 | 
             
                include Ignorable
         | 
| @@ -12,15 +11,12 @@ module Airbrake | |
| 12 11 | 
             
                include Mergeable
         | 
| 13 12 | 
             
                include Grouppable
         | 
| 14 13 |  | 
| 15 | 
            -
                attr_accessor :method, :route, :status_code, : | 
| 16 | 
            -
                              :timing, :time
         | 
| 14 | 
            +
                attr_accessor :method, :route, :status_code, :timing, :time
         | 
| 17 15 |  | 
| 18 16 | 
             
                def initialize(
         | 
| 19 17 | 
             
                  method:,
         | 
| 20 18 | 
             
                  route:,
         | 
| 21 19 | 
             
                  status_code:,
         | 
| 22 | 
            -
                  start_time: Time.now,
         | 
| 23 | 
            -
                  end_time: start_time + 1,
         | 
| 24 20 | 
             
                  timing: nil,
         | 
| 25 21 | 
             
                  time: Time.now
         | 
| 26 22 | 
             
                )
         | 
| @@ -28,8 +24,6 @@ module Airbrake | |
| 28 24 | 
             
                  @method = method
         | 
| 29 25 | 
             
                  @route = route
         | 
| 30 26 | 
             
                  @status_code = status_code
         | 
| 31 | 
            -
                  @start_time = start_time
         | 
| 32 | 
            -
                  @end_time = end_time
         | 
| 33 27 | 
             
                  @timing = timing
         | 
| 34 28 | 
             
                  @time = time
         | 
| 35 29 | 
             
                end
         | 
| @@ -51,5 +45,4 @@ module Airbrake | |
| 51 45 | 
             
                  }.delete_if { |_key, val| val.nil? }
         | 
| 52 46 | 
             
                end
         | 
| 53 47 | 
             
              end
         | 
| 54 | 
            -
              # rubocop:enable Metrics/ParameterLists
         | 
| 55 48 | 
             
            end
         | 
    
        data/lib/airbrake-ruby/stat.rb
    CHANGED
    
    | @@ -9,7 +9,7 @@ module Airbrake | |
| 9 9 | 
             
              #
         | 
| 10 10 | 
             
              # @example
         | 
| 11 11 | 
             
              #   stat = Airbrake::Stat.new
         | 
| 12 | 
            -
              #   stat. | 
| 12 | 
            +
              #   stat.increment_ms(2000)
         | 
| 13 13 | 
             
              #   stat.to_h # Pack and serialize data so it can be transmitted.
         | 
| 14 14 | 
             
              #
         | 
| 15 15 | 
             
              # @since v3.2.0
         | 
| @@ -41,17 +41,6 @@ module Airbrake | |
| 41 41 | 
             
                  end
         | 
| 42 42 | 
             
                end
         | 
| 43 43 |  | 
| 44 | 
            -
                # Increments tdigest timings and updates tdigest with the difference between
         | 
| 45 | 
            -
                # +end_time+ and +start_time+.
         | 
| 46 | 
            -
                #
         | 
| 47 | 
            -
                # @param [Date] start_time
         | 
| 48 | 
            -
                # @param [Date] end_time
         | 
| 49 | 
            -
                # @return [void]
         | 
| 50 | 
            -
                def increment(start_time, end_time = nil)
         | 
| 51 | 
            -
                  end_time ||= Time.new
         | 
| 52 | 
            -
                  increment_ms((end_time - start_time) * 1000)
         | 
| 53 | 
            -
                end
         | 
| 54 | 
            -
             | 
| 55 44 | 
             
                # Increments tdigest timings and updates tdigest with given +ms+ value.
         | 
| 56 45 | 
             
                #
         | 
| 57 46 | 
             
                # @param [Float] ms
         | 
| @@ -200,6 +200,7 @@ module Airbrake | |
| 200 200 | 
             
                    unless (0..1).cover?(item)
         | 
| 201 201 | 
             
                      raise ArgumentError, "p should be in [0,1], got #{item}"
         | 
| 202 202 | 
             
                    end
         | 
| 203 | 
            +
             | 
| 203 204 | 
             
                    if size == 0
         | 
| 204 205 | 
             
                      nil
         | 
| 205 206 | 
             
                    else
         | 
| @@ -271,6 +272,7 @@ module Airbrake | |
| 271 272 | 
             
                      shift = 7
         | 
| 272 273 | 
             
                      while (v & 0x80) != 0
         | 
| 273 274 | 
             
                        raise 'Shift too large in decode' if shift > 28
         | 
| 275 | 
            +
             | 
| 274 276 | 
             
                        v = counts_bytes.shift || 0
         | 
| 275 277 | 
             
                        z += (v & 0x7f) << shift
         | 
| 276 278 | 
             
                        shift += 7
         | 
| @@ -12,6 +12,10 @@ module Airbrake | |
| 12 12 | 
             
                #   strings with +ENCODING_OPTIONS+
         | 
| 13 13 | 
             
                TEMP_ENCODING = 'utf-16'.freeze
         | 
| 14 14 |  | 
| 15 | 
            +
                # @return [Array<Encoding>] encodings that are eligible for fixing invalid
         | 
| 16 | 
            +
                #   characters
         | 
| 17 | 
            +
                SUPPORTED_ENCODINGS = [Encoding::UTF_8, Encoding::ASCII].freeze
         | 
| 18 | 
            +
             | 
| 15 19 | 
             
                # @return [String] what to append when something is a circular reference
         | 
| 16 20 | 
             
                CIRCULAR = '[Circular]'.freeze
         | 
| 17 21 |  | 
| @@ -35,6 +39,7 @@ module Airbrake | |
| 35 39 | 
             
                def truncate(object, seen = Set.new)
         | 
| 36 40 | 
             
                  if seen.include?(object.object_id)
         | 
| 37 41 | 
             
                    return CIRCULAR if CIRCULAR_TYPES.any? { |t| object.is_a?(t) }
         | 
| 42 | 
            +
             | 
| 38 43 | 
             
                    return object
         | 
| 39 44 | 
             
                  end
         | 
| 40 45 | 
             
                  truncate_object(object, seen << object.object_id)
         | 
| @@ -63,6 +68,7 @@ module Airbrake | |
| 63 68 | 
             
                def truncate_string(str)
         | 
| 64 69 | 
             
                  fixed_str = replace_invalid_characters(str)
         | 
| 65 70 | 
             
                  return fixed_str if fixed_str.length <= @max_size
         | 
| 71 | 
            +
             | 
| 66 72 | 
             
                  (fixed_str.slice(0, @max_size) + TRUNCATED).freeze
         | 
| 67 73 | 
             
                end
         | 
| 68 74 |  | 
| @@ -76,6 +82,7 @@ module Airbrake | |
| 76 82 | 
             
                  truncated_hash = {}
         | 
| 77 83 | 
             
                  hash.each_with_index do |(key, val), idx|
         | 
| 78 84 | 
             
                    break if idx + 1 > @max_size
         | 
| 85 | 
            +
             | 
| 79 86 | 
             
                    truncated_hash[key] = truncate(val, seen)
         | 
| 80 87 | 
             
                  end
         | 
| 81 88 |  | 
| @@ -103,8 +110,7 @@ module Airbrake | |
| 103 110 | 
             
                # @return [String] a UTF-8 encoded string
         | 
| 104 111 | 
             
                # @see https://github.com/flori/json/commit/3e158410e81f94dbbc3da6b7b35f4f64983aa4e3
         | 
| 105 112 | 
             
                def replace_invalid_characters(str)
         | 
| 106 | 
            -
                   | 
| 107 | 
            -
                  utf8_string = (encoding == Encoding::UTF_8 || encoding == Encoding::ASCII)
         | 
| 113 | 
            +
                  utf8_string = SUPPORTED_ENCODINGS.include?(str.encoding)
         | 
| 108 114 | 
             
                  return str if utf8_string && str.valid_encoding?
         | 
| 109 115 |  | 
| 110 116 | 
             
                  temp_str = str.dup
         | 
| @@ -3,10 +3,10 @@ | |
| 3 3 | 
             
            module Airbrake
         | 
| 4 4 | 
             
              # @return [String] the library version
         | 
| 5 5 | 
             
              # @api public
         | 
| 6 | 
            -
              AIRBRAKE_RUBY_VERSION = '5.0. | 
| 6 | 
            +
              AIRBRAKE_RUBY_VERSION = '5.0.1'.freeze
         | 
| 7 7 |  | 
| 8 8 | 
             
              # @return [Hash{Symbol=>String}] the information about the notifier library
         | 
| 9 | 
            -
              # @since  | 
| 9 | 
            +
              # @since 5.0.0
         | 
| 10 10 | 
             
              # @api public
         | 
| 11 11 | 
             
              NOTIFIER_INFO = {
         | 
| 12 12 | 
             
                name: 'airbrake-ruby'.freeze,
         | 
    
        data/spec/backtrace_spec.rb
    CHANGED
    
    | @@ -2,7 +2,7 @@ RSpec.describe Airbrake::Backtrace do | |
| 2 2 | 
             
              describe ".parse" do
         | 
| 3 3 | 
             
                context "UNIX backtrace" do
         | 
| 4 4 | 
             
                  let(:parsed_backtrace) do
         | 
| 5 | 
            -
                    # rubocop:disable  | 
| 5 | 
            +
                    # rubocop:disable Layout/LineLength, Style/HashSyntax, Layout/SpaceAroundOperators, Layout/SpaceInsideHashLiteralBraces
         | 
| 6 6 | 
             
                    [{:file=>"/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb", :line=>23, :function=>"<top (required)>"},
         | 
| 7 7 | 
             
                     {:file=>"/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb", :line=>54, :function=>"require"},
         | 
| 8 8 | 
             
                     {:file=>"/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb", :line=>54, :function=>"require"},
         | 
| @@ -16,7 +16,7 @@ RSpec.describe Airbrake::Backtrace do | |
| 16 16 | 
             
                     {:file=>"/home/kyrylo/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb", :line=>73, :function=>"run"},
         | 
| 17 17 | 
             
                     {:file=>"/home/kyrylo/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb", :line=>41, :function=>"invoke"},
         | 
| 18 18 | 
             
                     {:file=>"/home/kyrylo/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/exe/rspec", :line=>4, :function=>"<main>"}]
         | 
| 19 | 
            -
                    # rubocop:enable  | 
| 19 | 
            +
                    # rubocop:enable Layout/LineLength, Style/HashSyntax, Layout/SpaceAroundOperators, Layout/SpaceInsideHashLiteralBraces
         | 
| 20 20 | 
             
                  end
         | 
| 21 21 |  | 
| 22 22 | 
             
                  it "returns a properly formatted array of hashes" do
         | 
| @@ -34,10 +34,10 @@ RSpec.describe Airbrake::Backtrace do | |
| 34 34 | 
             
                  let(:ex) { AirbrakeTestError.new.tap { |e| e.set_backtrace(windows_bt) } }
         | 
| 35 35 |  | 
| 36 36 | 
             
                  let(:parsed_backtrace) do
         | 
| 37 | 
            -
                    # rubocop:disable  | 
| 37 | 
            +
                    # rubocop:disable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
         | 
| 38 38 | 
             
                    [{:file=>"C:/Program Files/Server/app/models/user.rb", :line=>13, :function=>"magic"},
         | 
| 39 39 | 
             
                     {:file=>"C:/Program Files/Server/app/controllers/users_controller.rb", :line=>8, :function=>"index"}]
         | 
| 40 | 
            -
                    # rubocop:enable  | 
| 40 | 
            +
                    # rubocop:enable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
         | 
| 41 41 | 
             
                  end
         | 
| 42 42 |  | 
| 43 43 | 
             
                  it "returns a properly formatted array of hashes" do
         | 
| @@ -47,7 +47,7 @@ RSpec.describe Airbrake::Backtrace do | |
| 47 47 |  | 
| 48 48 | 
             
                context "JRuby Java exceptions" do
         | 
| 49 49 | 
             
                  let(:backtrace_array) do
         | 
| 50 | 
            -
                    # rubocop:disable  | 
| 50 | 
            +
                    # rubocop:disable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
         | 
| 51 51 | 
             
                    [{:file=>"InstanceMethodInvoker.java", :line=>26, :function=>"org.jruby.java.invokers.InstanceMethodInvoker.call"},
         | 
| 52 52 | 
             
                     {:file=>"Interpreter.java", :line=>126, :function=>"org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL"},
         | 
| 53 53 | 
             
                     {:file=>"RubyKernel$INVOKER$s$0$3$eval19.gen", :line=>nil, :function=>"org.jruby.RubyKernel$INVOKER$s$0$3$eval19.call"},
         | 
| @@ -59,7 +59,7 @@ RSpec.describe Airbrake::Backtrace do | |
| 59 59 | 
             
                     {:file=>"Compiler.java", :line=>111, :function=>"org.jruby.ir.Compiler$1.load"},
         | 
| 60 60 | 
             
                     {:file=>"Main.java", :line=>225, :function=>"org.jruby.Main.run"},
         | 
| 61 61 | 
             
                     {:file=>"Main.java", :line=>197, :function=>"org.jruby.Main.main"}]
         | 
| 62 | 
            -
                    # rubocop:enable  | 
| 62 | 
            +
                    # rubocop:enable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
         | 
| 63 63 | 
             
                  end
         | 
| 64 64 |  | 
| 65 65 | 
             
                  it "returns a properly formatted array of hashes" do
         | 
| @@ -72,21 +72,21 @@ RSpec.describe Airbrake::Backtrace do | |
| 72 72 |  | 
| 73 73 | 
             
                context "JRuby classloader exceptions" do
         | 
| 74 74 | 
             
                  let(:backtrace) do
         | 
| 75 | 
            -
                    # rubocop:disable  | 
| 75 | 
            +
                    # rubocop:disable Layout/LineLength
         | 
| 76 76 | 
             
                    ['uri_3a_classloader_3a_.META_minus_INF.jruby_dot_home.lib.ruby.stdlib.net.protocol.rbuf_fill(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/protocol.rb:158)',
         | 
| 77 77 | 
             
                     'bin.processors.image_uploader.block in make_streams(bin/processors/image_uploader.rb:21)',
         | 
| 78 78 | 
             
                     'uri_3a_classloader_3a_.gems.faye_minus_websocket_minus_0_dot_10_dot_5.lib.faye.websocket.api.invokeOther13:dispatch_event(uri_3a_classloader_3a_/gems/faye_minus_websocket_minus_0_dot_10_dot_5/lib/faye/websocket/uri:classloader:/gems/faye-websocket-0.10.5/lib/faye/websocket/api.rb:109)',
         | 
| 79 79 | 
             
                     'tmp.jruby9022301782566983632extract.$dot.META_minus_INF.rails.file(/tmp/jruby9022301782566983632extract/./META-INF/rails.rb:13)']
         | 
| 80 | 
            -
                    # rubocop:enable  | 
| 80 | 
            +
                    # rubocop:enable Layout/LineLength
         | 
| 81 81 | 
             
                  end
         | 
| 82 82 |  | 
| 83 83 | 
             
                  let(:parsed_backtrace) do
         | 
| 84 | 
            -
                    # rubocop:disable  | 
| 84 | 
            +
                    # rubocop:disable Layout/LineLength
         | 
| 85 85 | 
             
                    [{ file: 'uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/protocol.rb', line: 158, function: 'uri_3a_classloader_3a_.META_minus_INF.jruby_dot_home.lib.ruby.stdlib.net.protocol.rbuf_fill' },
         | 
| 86 86 | 
             
                     { file: 'bin/processors/image_uploader.rb', line: 21, function: 'bin.processors.image_uploader.block in make_streams' },
         | 
| 87 87 | 
             
                     { file: 'uri_3a_classloader_3a_/gems/faye_minus_websocket_minus_0_dot_10_dot_5/lib/faye/websocket/uri:classloader:/gems/faye-websocket-0.10.5/lib/faye/websocket/api.rb', line: 109, function: 'uri_3a_classloader_3a_.gems.faye_minus_websocket_minus_0_dot_10_dot_5.lib.faye.websocket.api.invokeOther13:dispatch_event' },
         | 
| 88 88 | 
             
                     { file: '/tmp/jruby9022301782566983632extract/./META-INF/rails.rb', line: 13, function: 'tmp.jruby9022301782566983632extract.$dot.META_minus_INF.rails.file' }]
         | 
| 89 | 
            -
                    # rubocop:enable  | 
| 89 | 
            +
                    # rubocop:enable Layout/LineLength
         | 
| 90 90 | 
             
                  end
         | 
| 91 91 |  | 
| 92 92 | 
             
                  let(:ex) { JavaAirbrakeTestError.new.tap { |e| e.set_backtrace(backtrace) } }
         | 
| @@ -99,19 +99,19 @@ RSpec.describe Airbrake::Backtrace do | |
| 99 99 |  | 
| 100 100 | 
             
                context "JRuby non-throwable exceptions" do
         | 
| 101 101 | 
             
                  let(:backtrace) do
         | 
| 102 | 
            -
                    # rubocop:disable  | 
| 102 | 
            +
                    # rubocop:disable Layout/LineLength
         | 
| 103 103 | 
             
                    ['org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(org/postgresql/core/v3/ConnectionFactoryImpl.java:257)',
         | 
| 104 104 | 
             
                     'org.postgresql.core.ConnectionFactory.openConnection(org/postgresql/core/ConnectionFactory.java:65)',
         | 
| 105 105 | 
             
                     'org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(org/postgresql/jdbc2/AbstractJdbc2Connection.java:149)']
         | 
| 106 | 
            -
                    # rubocop:enable  | 
| 106 | 
            +
                    # rubocop:enable Layout/LineLength
         | 
| 107 107 | 
             
                  end
         | 
| 108 108 |  | 
| 109 109 | 
             
                  let(:parsed_backtrace) do
         | 
| 110 | 
            -
                    # rubocop:disable  | 
| 110 | 
            +
                    # rubocop:disable Layout/LineLength
         | 
| 111 111 | 
             
                    [{ file: 'org/postgresql/core/v3/ConnectionFactoryImpl.java', line: 257, function: 'org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl' },
         | 
| 112 112 | 
             
                     { file: 'org/postgresql/core/ConnectionFactory.java', line: 65, function: 'org.postgresql.core.ConnectionFactory.openConnection' },
         | 
| 113 113 | 
             
                     { file: 'org/postgresql/jdbc2/AbstractJdbc2Connection.java', line: 149, function: 'org.postgresql.jdbc2.AbstractJdbc2Connection.<init>' }]
         | 
| 114 | 
            -
                    # rubocop:enable  | 
| 114 | 
            +
                    # rubocop:enable Layout/LineLength
         | 
| 115 115 | 
             
                  end
         | 
| 116 116 |  | 
| 117 117 | 
             
                  let(:ex) { AirbrakeTestError.new.tap { |e| e.set_backtrace(backtrace) } }
         | 
| @@ -123,22 +123,22 @@ RSpec.describe Airbrake::Backtrace do | |
| 123 123 |  | 
| 124 124 | 
             
                context "generic backtrace" do
         | 
| 125 125 | 
             
                  context "when function is absent" do
         | 
| 126 | 
            -
                    # rubocop:disable  | 
| 126 | 
            +
                    # rubocop:disable Layout/LineLength
         | 
| 127 127 | 
             
                    let(:generic_bt) do
         | 
| 128 128 | 
             
                      ["/home/bingo/bango/assets/stylesheets/error_pages.scss:139:in `animation'",
         | 
| 129 129 | 
             
                       "/home/bingo/bango/assets/stylesheets/error_pages.scss:139",
         | 
| 130 130 | 
             
                       "/home/bingo/.gem/ruby/2.2.2/gems/sass-3.4.20/lib/sass/tree/visitors/perform.rb:349:in `block in visit_mixin'"]
         | 
| 131 131 | 
             
                    end
         | 
| 132 | 
            -
                    # rubocop:enable  | 
| 132 | 
            +
                    # rubocop:enable Layout/LineLength
         | 
| 133 133 |  | 
| 134 134 | 
             
                    let(:ex) { AirbrakeTestError.new.tap { |e| e.set_backtrace(generic_bt) } }
         | 
| 135 135 |  | 
| 136 136 | 
             
                    let(:parsed_backtrace) do
         | 
| 137 | 
            -
                      # rubocop:disable  | 
| 137 | 
            +
                      # rubocop:disable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
         | 
| 138 138 | 
             
                      [{:file=>"/home/bingo/bango/assets/stylesheets/error_pages.scss", :line=>139, :function=>"animation"},
         | 
| 139 139 | 
             
                       {:file=>"/home/bingo/bango/assets/stylesheets/error_pages.scss", :line=>139, :function=>nil},
         | 
| 140 140 | 
             
                       {:file=>"/home/bingo/.gem/ruby/2.2.2/gems/sass-3.4.20/lib/sass/tree/visitors/perform.rb", :line=>349, :function=>"block in visit_mixin"}]
         | 
| 141 | 
            -
                      # rubocop:enable  | 
| 141 | 
            +
                      # rubocop:enable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
         | 
| 142 142 | 
             
                    end
         | 
| 143 143 |  | 
| 144 144 | 
             
                    it "returns a properly formatted array of hashes" do
         | 
| @@ -277,9 +277,9 @@ RSpec.describe Airbrake::Backtrace do | |
| 277 277 | 
             
                            93 => '        begin',
         | 
| 278 278 | 
             
                            94 => '          json = @payload.to_json',
         | 
| 279 279 | 
             
                            95 => '        rescue *JSON_EXCEPTIONS => ex',
         | 
| 280 | 
            -
                            # rubocop:disable  | 
| 280 | 
            +
                            # rubocop:disable Layout/LineLength,Lint/InterpolationCheck
         | 
| 281 281 | 
             
                            96 => '          @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
         | 
| 282 | 
            -
                            # rubocop:enable  | 
| 282 | 
            +
                            # rubocop:enable Layout/LineLength,Lint/InterpolationCheck
         | 
| 283 283 | 
             
                          },
         | 
| 284 284 | 
             
                        },
         | 
| 285 285 | 
             
                        {
         | 
| @@ -325,9 +325,9 @@ RSpec.describe Airbrake::Backtrace do | |
| 325 325 | 
             
                            93 => '        begin',
         | 
| 326 326 | 
             
                            94 => '          json = @payload.to_json',
         | 
| 327 327 | 
             
                            95 => '        rescue *JSON_EXCEPTIONS => ex',
         | 
| 328 | 
            -
                            # rubocop:disable  | 
| 328 | 
            +
                            # rubocop:disable Layout/LineLength,Lint/InterpolationCheck
         | 
| 329 329 | 
             
                            96 => '          @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
         | 
| 330 | 
            -
                            # rubocop:enable  | 
| 330 | 
            +
                            # rubocop:enable Layout/LineLength,Lint/InterpolationCheck
         | 
| 331 331 | 
             
                          },
         | 
| 332 332 | 
             
                        },
         | 
| 333 333 | 
             
                      ]
         | 
| @@ -357,9 +357,9 @@ RSpec.describe Airbrake::Backtrace do | |
| 357 357 | 
             
                            93 => '        begin',
         | 
| 358 358 | 
             
                            94 => '          json = @payload.to_json',
         | 
| 359 359 | 
             
                            95 => '        rescue *JSON_EXCEPTIONS => ex',
         | 
| 360 | 
            -
                            # rubocop:disable  | 
| 360 | 
            +
                            # rubocop:disable Layout/LineLength,Lint/InterpolationCheck
         | 
| 361 361 | 
             
                            96 => '          @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
         | 
| 362 | 
            -
                            # rubocop:enable  | 
| 362 | 
            +
                            # rubocop:enable Layout/LineLength,Lint/InterpolationCheck
         | 
| 363 363 | 
             
                          },
         | 
| 364 364 | 
             
                        },
         | 
| 365 365 | 
             
                        {
         | 
| @@ -370,9 +370,9 @@ RSpec.describe Airbrake::Backtrace do | |
| 370 370 | 
             
                            93 => '        begin',
         | 
| 371 371 | 
             
                            94 => '          json = @payload.to_json',
         | 
| 372 372 | 
             
                            95 => '        rescue *JSON_EXCEPTIONS => ex',
         | 
| 373 | 
            -
                            # rubocop:disable  | 
| 373 | 
            +
                            # rubocop:disable Layout/LineLength,Lint/InterpolationCheck
         | 
| 374 374 | 
             
                            96 => '          @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
         | 
| 375 | 
            -
                            # rubocop:enable  | 
| 375 | 
            +
                            # rubocop:enable Layout/LineLength,Lint/InterpolationCheck
         | 
| 376 376 | 
             
                            97 => '        else',
         | 
| 377 377 | 
             
                          },
         | 
| 378 378 | 
             
                        },
         |