class Mmtrix::Agent::Configuration::DefaultSource

Attributes

defaults[R]

Public Class Methods

agent_enabled() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 102
def self.agent_enabled
  Proc.new {
    Mmtrix::Agent.config[:enabled] &&
    (Mmtrix::Agent.config[:developer_mode] || Mmtrix::Agent.config[:monitor_mode]) &&
    Mmtrix::Agent::Autostart.agent_should_start?
  }
end
app_name() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 116
def self.app_name
  Proc.new { Mmtrix::Control.instance.env }
end
audit_log_path() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 110
def self.audit_log_path
  Proc.new {
    File.join(Mmtrix::Agent.config[:log_file_path], 'mmtrix_audit.log')
  }
end
browser_monitoring_loader() click to toggle source

This check supports the js_errors_beta key we’ve asked clients to set. Once JS errors are GA, browser_monitoring.loader can stop being dynamic.

# File lib/mmtrix/agent/configuration/default_source.rb, line 142
def self.browser_monitoring_loader
  Proc.new { Mmtrix::Agent.config[:js_errors_beta] ? "full" : "rum"}
end
config_path() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 70
def self.config_path
  Proc.new {
    found_path = Mmtrix::Agent.config[:config_search_paths].detect do |file|
      File.expand_path(file) if File.exist? file
    end
    found_path || ""
  }
end
config_search_paths() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 43
def self.config_search_paths
  Proc.new {
    paths = [
      File.join("config","mmtrix.yml"),
      File.join("mmtrix.yml")
    ]

    if Mmtrix::Control.instance.root
      paths << File.join(Mmtrix::Control.instance.root, "config", "mmtrix.yml")
      paths << File.join(Mmtrix::Control.instance.root, "mmtrix.yml")
    end

    if ENV["HOME"]
      paths << File.join(ENV["HOME"], ".mmtrix", "mmtrix.yml")
      paths << File.join(ENV["HOME"], "mmtrix.yml")
    end

    # If we're packaged for warbler, we can tell from GEM_HOME
    if ENV["GEM_HOME"] && ENV["GEM_HOME"].end_with?(".jar!")
      app_name = File.basename(ENV["GEM_HOME"], ".jar!")
      paths << File.join(ENV["GEM_HOME"], app_name, "config", "mmtrix.yml")
    end

    paths
  }
end
convert_to_constant_list(raw_value) click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 183
def self.convert_to_constant_list(raw_value)
  const_names = convert_to_list(raw_value)
  const_names.map! do |class_name|
    const = ::Mmtrix::LanguageSupport.constantize(class_name)

    unless const
      Mmtrix::Agent.logger.warn("Ignoring unrecognized constant '#{class_name}' in #{raw_value}")
    end

    const
  end
  const_names.compact
end
convert_to_list(value) click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 172
def self.convert_to_list(value)
  case value
  when String
    value.split(/\s*,\s*/)
  when Array
    value
  else
    raise ArgumentError.new("Config value '#{value}' couldn't be turned into a list.")
  end
end
convert_to_regexp_list(raw_value) click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 165
def self.convert_to_regexp_list(raw_value)
  value_list = convert_to_list(raw_value)
  value_list.map do |value|
    /#{value}/
  end
end
dispatcher() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 120
def self.dispatcher
  Proc.new { Mmtrix::Control.instance.local_env.discovered_dispatcher }
end
framework() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 79
def self.framework
  Proc.new {
    case
    when defined?(::Mmtrix::TEST) then :test
    when defined?(::Merb) && defined?(::Merb::Plugins) then :merb
    when defined?(::Rails::VERSION)
      case Rails::VERSION::MAJOR
      when 0..2
        :rails
      when 3
        :rails3
      when 4
        :rails4
      else
        ::Mmtrix::Agent.logger.error "Detected unsupported Rails version #{Rails::VERSION::STRING}"
      end
    when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
    when defined?(::Mmtrix::IA) then :external
    else :ruby
    end
  }
end
marshaller() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 124
def self.marshaller
  Proc.new { Mmtrix::Agent::MmtrixService::JsonMarshaller.is_supported? ? 'json' : 'pruby' }
end
new() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 26
def initialize
  @defaults = default_values
end
normalize_json_string_encodings() click to toggle source

On Rubies with string encodings support (1.9.x+), default to always normalize encodings since it’s safest and fast. Without that support the conversions are too expensive, so only enable if overridden to.

# File lib/mmtrix/agent/configuration/default_source.rb, line 131
def self.normalize_json_string_encodings
  Proc.new { Mmtrix::LanguageSupport.supports_string_encodings? }
end
port() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 150
def self.port
  Proc.new { Mmtrix::Agent.config[:ssl] ? 443 : 80 }
end
profiling_available() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 154
def self.profiling_available
  Proc.new {
    begin
      require 'ruby-prof'
      true
    rescue LoadError
      false
    end
  }
end
thread_profiler_enabled() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 135
def self.thread_profiler_enabled
  Proc.new { Mmtrix::Agent::Threading::BacktraceService.is_supported? }
end
transaction_tracer_transaction_threshold() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 146
def self.transaction_tracer_transaction_threshold
  Proc.new { Mmtrix::Agent.config[:apdex_t] * 4 }
end
transform_for(key) click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 38
def self.transform_for(key)
  default_settings = ::Mmtrix::Agent::Configuration::DEFAULTS[key]
  default_settings[:transform] if default_settings
end

Public Instance Methods

default_values() click to toggle source
# File lib/mmtrix/agent/configuration/default_source.rb, line 30
def default_values
  result = {}
  ::Mmtrix::Agent::Configuration::DEFAULTS.each do |key, value|
    result[key] = value[:default]
  end
  result
end