Sha256: 7415c375346801b7535a2c8d5eeefa2dbf8e42afa152bdb0a6e5fc1c46c81761

Contents?: true

Size: 939 Bytes

Versions: 5

Compression:

Stored size: 939 Bytes

Contents

require "logger"

require "racecar/consumer"
require "racecar/runner"
require "racecar/config"

module Racecar
  # Ignores all instrumentation events.
  class NullInstrumenter
    def self.instrument(*)
      yield if block_given?
    end
  end

  class Error < StandardError
  end

  class ConfigError < Error
  end

  def self.config
    @config ||= Config.new
  end

  def self.config=(config)
    @config = config
  end

  def self.configure
    yield config
  end

  def self.logger
    config.logger
  end

  def self.logger=(logger)
    config.logger = logger
  end

  def self.instrumenter
    require "active_support/notifications"

    ActiveSupport::Notifications
  rescue LoadError
    logger.warn "ActiveSupport::Notifications not available, instrumentation is disabled"

    NullInstrumenter
  end

  def self.run(processor)
    Runner.new(processor, config: config, logger: logger, instrumenter: instrumenter).run
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
racecar-1.3.0 lib/racecar.rb
racecar-1.2.1 lib/racecar.rb
racecar-1.2.0 lib/racecar.rb
racecar-1.1.0 lib/racecar.rb
racecar-1.0.1 lib/racecar.rb