<commit_before>require "httparty"
require "logger"
require "json"
require "socket"
require "rack"
require "ostruct"

require "raygun/version"
require "raygun/configuration"
require "raygun/client"
require "raygun/middleware/rack_exception_interceptor"
require "raygun/testable"
require "raygun/services/apply_whitelist_filter_to_payload"
require "raygun/railtie" if defined?(Rails)
begin
  require "pry"
rescue LoadError
end

module Raygun

  # used to identify ourselves to Raygun
  CLIENT_URL  = "https://github.com/MindscapeHQ/raygun4ruby"
  CLIENT_NAME = "Raygun4Ruby Gem"

  class << self

    include Testable

    # Configuration Object (instance of Raygun::Configuration)
    attr_writer :configuration

    def setup
      yield(configuration)
    end

    def configuration
      @configuration ||= Configuration.new
    end

    def default_configuration
      configuration.defaults
    end

    def configured?
      !!configuration.api_key
    end

    def track_exception(exception_instance, env = {})
      if should_report?(exception_instance)
        log("[Raygun] Tracking Exception...")
        Client.new.track_exception(exception_instance, env)
      end
    rescue Exception => e
      if configuration.failsafe_logger
        failsafe_log("Problem reporting exception to Raygun: #{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}")
      else
        raise e
      end
    end<commit_msg>Notify raygun when raygun4ruby raises an exception<commit_after>require "httparty"
require "logger"
require "json"
require "socket"
require "rack"
require "ostruct"

require "raygun/version"
require "raygun/configuration"
require "raygun/client"
require "raygun/middleware/rack_exception_interceptor"
require "raygun/testable"
require "raygun/services/apply_whitelist_filter_to_payload"
require "raygun/railtie" if defined?(Rails)
begin
  require "pry"
rescue LoadError
end

module Raygun

  # used to identify ourselves to Raygun
  CLIENT_URL  = "https://github.com/MindscapeHQ/raygun4ruby"
  CLIENT_NAME = "Raygun4Ruby Gem"

  class << self

    include Testable

    # Configuration Object (instance of Raygun::Configuration)
    attr_writer :configuration

    def setup
      yield(configuration)
    end

    def configuration
      @configuration ||= Configuration.new
    end

    def default_configuration
      configuration.defaults
    end

    def configured?
      !!configuration.api_key
    end

    def track_exception(exception_instance, env = {}, retry_count = 1)
      if should_report?(exception_instance)
        log("[Raygun] Tracking Exception...")
        Client.new.track_exception(exception_instance, env)
      end
    rescue Exception => e
      if configuration.failsafe_logger
        failsafe_log("Problem reporting exception to Raygun: #{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}")
      end

      if retry_count > 0
        new_exception = e.exception("raygun4ruby encountered an exception processing your exception")
        new_exception.set_backtrace(e.backtrace)

        env[:custom_data] ||= {}
        env[:custom_data].merge!(original_stacktrace: exception_instance.backtrace)

        track_exception(new_exception, env, retry_count - 1)
      else
        raise e
      end
    end
{'fraction_non_alphanumeric': 0.08951091971701015, 'fraction_numerical': 0.0027683789603199014, 'mean_word_length': 3.6062322946175636, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 2, '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': '5235075', 'n_tokens_mistral': 978, 'n_tokens_neox': 942, 'n_words': 233}