<commit_before>module Aws
  module Xray
    attrs = [:method, :url, :user_agent, :client_ip, :x_forwarded_for, :traced]
    class Request < Struct.new(*attrs)
      def self.build_from_rack_env(env)
        new(
          env['REQUEST_METHOD'], # method
          env['REQUEST_URI'], # url
          env['HTTP_USER_AGENT'], # user_agent
          env['X-Forwarded-For'], # client_ip
          !!env['X-Forwarded-For'], # x_forwarded_for
          false, # traced
        )
      end

      def self.build_from_faraday_env(env)
        new(
          env.method.to_s.upcase, # method
          env.url.to_s, # url
          env.request_headers['User-Agent'], # user_agent
          nil, # client_ip
          false, # x_forwarded_for
          false, # traced
        )
      end
    end
  end<commit_msg>Add Request.build to accept keyword argument<commit_after>module Aws
  module Xray
    attrs = [:method, :url, :user_agent, :client_ip, :x_forwarded_for, :traced]
    class Request < Struct.new(*attrs)
      class << self
        def build(method:, url:, user_agent: nil, client_ip: nil, x_forwarded_for: nil, traced: false)
          new(method, url, user_agent, client_ip, x_forwarded_for, traced)
        end

        def build_from_rack_env(env)
          build(
            method: env['REQUEST_METHOD'],
            url: env['REQUEST_URI'],
            user_agent: env['HTTP_USER_AGENT'],
            client_ip: env['X-Forwarded-For'],
            x_forwarded_for: !!env['X-Forwarded-For'],
            traced: false,
          )
        end

        def build_from_faraday_env(env)
          build(
            method: env.method.to_s.upcase,
            url: env.url.to_s,
            user_agent: env.request_headers['User-Agent'],
            client_ip: nil,
            x_forwarded_for: false,
            traced: false,
          )
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.1099893730074389, 'fraction_numerical': 0.0, 'mean_word_length': 1.9700315457413249, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5488903', 'n_tokens_mistral': 609, 'n_tokens_neox': 597, 'n_words': 121}