Class: Airbrake::Filters::GemRootFilter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake-ruby/filters/gem_root_filter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Replaces paths to gems with a placeholder.

Constant Summary collapse

GEM_ROOT_LABEL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns:

  • (String)
'/GEM_ROOT'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGemRootFilter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of GemRootFilter.



12
13
14
# File 'lib/airbrake-ruby/filters/gem_root_filter.rb', line 12

def initialize
  @weight = 120
end

Instance Attribute Details

#weightInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


10
11
12
# File 'lib/airbrake-ruby/filters/gem_root_filter.rb', line 10

def weight
  @weight
end

Instance Method Details

#call(notice) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

This is a mandatory method required by any filter integrated with FilterChain.

Parameters:

  • notice (Notice)

    the notice to be filtered

See Also:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/airbrake-ruby/filters/gem_root_filter.rb', line 17

def call(notice)
  return unless defined?(Gem)

  notice[:errors].each do |error|
    Gem.path.each do |gem_path|
      error[:backtrace].each do |frame|
        # If the frame is unparseable, then 'file' is nil, thus nothing to
        # filter (all frame's data is in 'function' instead).
        next unless (file = frame[:file])

        frame[:file] = file.sub(/\A#{gem_path}/, GEM_ROOT_LABEL)
      end
    end
  end
end