class ElasticAPM::Transport::Filters::SecretsFilter

@api private

def call(payload)

def call(payload)
  strip_from! payload.dig(:transaction, :context, :request, :headers)
  strip_from! payload.dig(:transaction, :context, :request, :env)
  strip_from! payload.dig(:transaction, :context, :response, :headers)
  strip_from! payload.dig(:error, :context, :request, :headers)
  strip_from! payload.dig(:error, :context, :response, :headers)
  strip_from! payload.dig(:transaction, :context, :request, :body)
  payload
end

def filter_key?(key)

def filter_key?(key)
  @key_filters.any? { |regex| key.match regex }
end

def filter_value?(value)

def filter_value?(value)
  VALUE_FILTERS.any? { |regex| value.match regex }
end

def initialize(config)

def initialize(config)
  @config = config
  @key_filters = KEY_FILTERS + config.custom_key_filters
end

def strip_from!(obj)

rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
def strip_from!(obj)
  return unless obj && obj.is_a?(Hash)
  obj.each do |k, v|
    if filter_key?(k)
      next obj[k] = FILTERED
    end
    case v
    when Hash
      strip_from!(v)
    when String
      if filter_value?(v)
        obj[k] = FILTERED
      end
    end
  end
end