Sha256: 4bb69d800bdf6e0ca1cebdd63e83e28159fd3f1c955e84f7dfae6d90b5b5567a

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'set'
require 'logger'

require 'heimdall_apm/vault'
require 'heimdall_apm/recorder'
require 'heimdall_apm/config'
require 'heimdall_apm/uri_matcher'

module HeimdallApm
  # Global context in which the agent is run. One context is assigned per
  # agent. It contains most of the part that are going to be accessed globally
  # by the rest of the monitoring.
  #
  class AgentContext
    # Global configuration object
    attr_writer :config

    def started!
      @started = true
    end

    def stopped!
      @started = false
    end

    def started?
      @started
    end

    def config
      @config ||= ::HeimdallApm::Config.new
    end

    def logger
      @logger ||= begin
        logger = Logger.new('log/heimdall_apm.log')
        logger.level = config['log_level'].presence || :debug
        logger
      end
    end

    def vault
      @vault ||= ::HeimdallApm::Vault.new(self)
    end

    def recorder
      @recorder ||= ::HeimdallApm::Recorder.new
    end

    def ignored_uris
      @ignored_uris ||= ::HeimdallApm::UriMatcher.new(config.value('ignore'))
    end

    def interactive?
      defined?(::Rails::Console) && $stdout.isatty && $stdin.isatty
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heimdall_apm-0.1.3 lib/heimdall_apm/agent_context.rb