Class: OneApm::Configuration::DefaultSource

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/one_apm/configuration/default_source.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDefaultSource

Returns a new instance of DefaultSource.



20
21
22
# File 'lib/one_apm/configuration/default_source.rb', line 20

def initialize
  @defaults = default_values
end

Instance Attribute Details

#defaultsObject (readonly)

Returns the value of attribute defaults.



15
16
17
# File 'lib/one_apm/configuration/default_source.rb', line 15

def defaults
  @defaults
end

Class Method Details

.agent_enabledObject



85
86
87
88
89
90
91
# File 'lib/one_apm/configuration/default_source.rb', line 85

def self.agent_enabled
  Proc.new {
    OneApm::Manager.config[:enabled] &&
    OneApm::Manager.config[:monitor_mode] &&
    OneApm::Manager.agent_should_start?
  }
end

.app_nameObject



99
100
101
# File 'lib/one_apm/configuration/default_source.rb', line 99

def self.app_name
  Proc.new { OneApm::Probe.instance.env }
end

.audit_log_pathObject



93
94
95
96
97
# File 'lib/one_apm/configuration/default_source.rb', line 93

def self.audit_log_path
  Proc.new {
    File.join(OneApm::Manager.config[:log_file_path], 'oneapm_audit.log')
  }
end

.browser_monitoring_loaderObject

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.



125
126
127
# File 'lib/one_apm/configuration/default_source.rb', line 125

def self.browser_monitoring_loader
  Proc.new { OneApm::Manager.config[:js_errors_beta] ? "full" : "rum"}
end

.config_pathObject



51
52
53
54
55
56
57
58
# File 'lib/one_apm/configuration/default_source.rb', line 51

def self.config_path
  Proc.new {
    found_path = OneApm::Manager.config[:config_search_paths].detect do |file|
      File.expand_path(file) if File.exists? file
    end
    found_path || ""
  }
end

.config_search_pathsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/one_apm/configuration/default_source.rb', line 37

def self.config_search_paths
  Proc.new {
    paths = [File.join(OneApm::Probe.instance.root, "config", "oneapm.yml")]

    # JRuby war
    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", "oneapm.yml")
    end

    paths
  }
end

.convert_to_list(value) ⇒ Object



147
148
149
150
151
152
153
154
155
156
# File 'lib/one_apm/configuration/default_source.rb', line 147

def self.convert_to_list(value)
  case value
  when String
    value.split(',')
  when Array
    value
  else
    raise ArgumentError.new("Config value '#{value}' couldn't be turned into a list.")
  end
end

.dispatcherObject



103
104
105
# File 'lib/one_apm/configuration/default_source.rb', line 103

def self.dispatcher
  Proc.new { OneApm::Probe.instance.local_env.discovered_dispatcher }
end

.frameworkObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/one_apm/configuration/default_source.rb', line 60

def self.framework
  Proc.new {
    case
    when defined?(::OneApm::TEST) then :test
    when defined?(::Rails::VERSION)
      case Rails::VERSION::MAJOR
      when 0..2
        :rails
      when 3
        :rails3
      when 4
        :rails4
      when 5
        :rails5
      else
        OneApm::Manager.logger.error "Detected unsupported Rails version #{Rails::VERSION::STRING}"
        :rails
      end
    when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
    when defined?(::OneApm::IA) then :external
    else :ruby
    end
  }
end

.marshallerObject



107
108
109
# File 'lib/one_apm/configuration/default_source.rb', line 107

def self.marshaller
  Proc.new { OneApm::Support::JsonMarshaller.is_supported? ? 'json' : 'pruby' }
end

.normalize_json_string_encodingsObject

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.



114
115
116
# File 'lib/one_apm/configuration/default_source.rb', line 114

def self.normalize_json_string_encodings
  Proc.new { OneApm::LanguageSupport.supports_string_encodings? }
end

.portObject



133
134
135
# File 'lib/one_apm/configuration/default_source.rb', line 133

def self.port
  Proc.new { OneApm::Manager.config[:ssl] ? 443 : 80 }
end

.rules_ignoreObject



137
138
139
140
141
142
143
144
145
# File 'lib/one_apm/configuration/default_source.rb', line 137

def self.rules_ignore
  Proc.new do |rules|
    rules = convert_to_list(rules)

    rules.map do |rule|
      /#{rule}/
    end
  end
end

.thread_profiler_enabledObject



118
119
120
# File 'lib/one_apm/configuration/default_source.rb', line 118

def self.thread_profiler_enabled
  Proc.new { OneApm::Agent::Threading::BacktraceService.is_supported? }
end

.transaction_tracer_transaction_thresholdObject



129
130
131
# File 'lib/one_apm/configuration/default_source.rb', line 129

def self.transaction_tracer_transaction_threshold
  Proc.new { OneApm::Manager.config[:apdex_t] * 4 }
end

.transform_for(key) ⇒ Object



32
33
34
35
# File 'lib/one_apm/configuration/default_source.rb', line 32

def self.transform_for(key)
  default_settings = ::OneApm::Configuration::DEFAULTS[key]
  default_settings[:transform] if default_settings
end

Instance Method Details

#default_valuesObject



24
25
26
27
28
29
30
# File 'lib/one_apm/configuration/default_source.rb', line 24

def default_values
  result = {}
  ::OneApm::Configuration::DEFAULTS.each do |key, value|
    result[key] = value[:default]
  end
  result
end