<commit_before>$:.unshift(File.expand_path('../..', File.dirname(__FILE__)))

require 'bundler/setup'
require 'metriks/librato_metrics_reporter'
require 'travis/live/error_handler'
require 'travis/live/config'
require 'travis/live/pusher/worker'
require 'travis/live/middleware/metriks'
require 'travis/live/middleware/logging'
require 'unlimited-jce-policy-jdk7'
require 'travis/support/exceptions'
require 'travis/support/logging'
require 'travis/support/logger'
require 'travis/support/metrics'

module Travis
  class << self
    def env
     ENV['ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
    end

    def logger
      @logger ||= Logger.configure(Logger.new(STDOUT))
    end

    def logger=(logger)
      @logger = Logger.configure(logger)
    end

    def uuid=(uuid)
      Thread.current[:uuid] = uuid
    end

    def uuid
      Thread.current[:uuid] ||= SecureRandom.uuid
    end
  end
end

$stdout.sync = true

if Travis.config.sentry.dsn
  require 'raven'
  Raven.configure do |config|
    config.dsn = Travis.config.sentry.dsn

    config.current_environment = Travis.env
    config.environments = ["staging", "production"]
  end
end

p [:sidekiq_namespace, Travis.config.sidekiq.namespace]
p [:redis_url, Travis.config.redis.url]
Sidekiq.configure_server do |config|
  config.redis = {
    :url       => Travis.config.redis.url,
    :namespace => Travis.config.sidekiq.namespace
  }
  config.server_middleware do |chain|
    chain.add Travis::Live::Middleware::Metriks
    chain.add Travis::Live::Middleware::Logging

    if defined?(::Raven::Sidekiq)
      chain.remove(::Raven::Sidekiq)
    end

    chain.remove(Sidekiq::Middleware::Server::Logging)
    chain.add(Travis::Live::ErrorHandler)
  end
end

if Travis.config.sentry
  Travis::Exceptions::Reporter.start
end

Travis::Metrics.setup<commit_msg>Remove debug info<commit_after>$:.unshift(File.expand_path('../..', File.dirname(__FILE__)))

require 'bundler/setup'
require 'metriks/librato_metrics_reporter'
require 'travis/live/error_handler'
require 'travis/live/config'
require 'travis/live/pusher/worker'
require 'travis/live/middleware/metriks'
require 'travis/live/middleware/logging'
require 'unlimited-jce-policy-jdk7'
require 'travis/support/exceptions'
require 'travis/support/logging'
require 'travis/support/logger'
require 'travis/support/metrics'

module Travis
  class << self
    def env
     ENV['ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
    end

    def logger
      @logger ||= Logger.configure(Logger.new(STDOUT))
    end

    def logger=(logger)
      @logger = Logger.configure(logger)
    end

    def uuid=(uuid)
      Thread.current[:uuid] = uuid
    end

    def uuid
      Thread.current[:uuid] ||= SecureRandom.uuid
    end
  end
end

$stdout.sync = true

if Travis.config.sentry.dsn
  require 'raven'
  Raven.configure do |config|
    config.dsn = Travis.config.sentry.dsn

    config.current_environment = Travis.env
    config.environments = ["staging", "production"]
  end
end

Sidekiq.configure_server do |config|
  config.redis = {
    :url       => Travis.config.redis.url,
    :namespace => Travis.config.sidekiq.namespace
  }
  config.server_middleware do |chain|
    chain.add Travis::Live::Middleware::Metriks
    chain.add Travis::Live::Middleware::Logging

    if defined?(::Raven::Sidekiq)
      chain.remove(::Raven::Sidekiq)
    end

    chain.remove(Sidekiq::Middleware::Server::Logging)
    chain.add(Travis::Live::ErrorHandler)
  end
end

if Travis.config.sentry
  Travis::Exceptions::Reporter.start
end

Travis::Metrics.setup
{'fraction_non_alphanumeric': 0.13385387618516453, 'fraction_numerical': 0.0005577244841048522, 'mean_word_length': 4.0167832167832165, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1650054', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1242, 'n_words': 217}