Module: NewRelic::Control::Configuration

Included in:
NewRelic::Control
Defined in:
lib/new_relic/control/configuration.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



50
51
52
# File 'lib/new_relic/control/configuration.rb', line 50

def [](key)
  fetch(key)
end

#[]=(key, value) ⇒ Object



54
55
56
# File 'lib/new_relic/control/configuration.rb', line 54

def []=(key, value)
  settings[key] = value
end

#apdex_tObject



62
63
64
65
# File 'lib/new_relic/control/configuration.rb', line 62

def apdex_t
  # Always initialized with a default
  fetch('apdex_t').to_f
end

#app_namesObject



118
119
120
121
122
123
124
# File 'lib/new_relic/control/configuration.rb', line 118

def app_names
  case self['app_name']
  when Array then self['app_name']
  when String then self['app_name'].split(';')
  else [ env ]
  end
end

#capture_paramsObject



69
70
71
# File 'lib/new_relic/control/configuration.rb', line 69

def capture_params
  fetch('capture_params')
end

#developer_mode?Boolean

True if we are capturing data and displaying in /newrelic

Returns:

  • (Boolean)


78
79
80
# File 'lib/new_relic/control/configuration.rb', line 78

def developer_mode?
  fetch('developer_mode', fetch('developer'))
end

#dispatcherObject



115
116
117
# File 'lib/new_relic/control/configuration.rb', line 115

def dispatcher
  (self['dispatcher'] && self['dispatcher'].to_sym) || @local_env.dispatcher
end

#dispatcher_instance_idObject



111
112
113
# File 'lib/new_relic/control/configuration.rb', line 111

def dispatcher_instance_id
  self['dispatcher_instance_id'] || @local_env.dispatcher_instance_id
end

#episodes_enabled?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/new_relic/control/configuration.rb', line 82

def episodes_enabled?
  fetch('episodes_enabled', true)
end

#fetch(key, default = nil) ⇒ Object



58
59
60
# File 'lib/new_relic/control/configuration.rb', line 58

def fetch(key, default=nil)
  settings.fetch(key, default)
end

#license_keyObject



66
67
68
# File 'lib/new_relic/control/configuration.rb', line 66

def license_key
  fetch('license_key')
end

#merge_defaults(settings_hash) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/new_relic/control/configuration.rb', line 21

def merge_defaults(settings_hash)
  s = {
    'host' => 'collector.newrelic.com',
    'ssl' => false,
    'log_level' => 'info',
    'apdex_t' => 1.0
  }
  s.merge! settings_hash if settings_hash
  # monitor_daemons replaced with agent_enabled
  s['agent_enabled'] = s.delete('monitor_daemons') if s['agent_enabled'].nil? && s.include?('monitor_daemons')
  s
end

#merge_options(options, hash = self) ⇒ Object

Merge the given options into the config options. They might be a nested hash



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/new_relic/control/configuration.rb', line 36

def merge_options(options, hash=self)
  options.each do |key, val |
    case
    when key == :config then next
    when val.is_a?(Hash)
      merge_options(val, hash[key.to_s] ||= {})
    when val.nil?
      hash.delete(key.to_s)
    else
      hash[key.to_s] = val
    end
  end
end

#monitor_mode?Boolean

True if we are sending data to the server, monitoring production

Returns:

  • (Boolean)


73
74
75
# File 'lib/new_relic/control/configuration.rb', line 73

def monitor_mode?
  fetch('monitor_mode', fetch('enabled'))
end

#multi_threaded?Boolean

True if the app runs in multi-threaded mode

Returns:

  • (Boolean)


86
87
88
# File 'lib/new_relic/control/configuration.rb', line 86

def multi_threaded?
  fetch('multi_threaded')
end

#post_size_limitObject



93
94
95
# File 'lib/new_relic/control/configuration.rb', line 93

def post_size_limit
  fetch('post_size_limit', 2 * 1024 * 1024)
end

#send_data_on_exitObject

Configuration option of the same name to indicate that we should flush data to the server on exiting. Defaults to true.



107
108
109
# File 'lib/new_relic/control/configuration.rb', line 107

def send_data_on_exit
  fetch('send_data_on_exit', true)
end

#settingsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/new_relic/control/configuration.rb', line 4

def settings
  unless @settings
    @settings = (@yaml && merge_defaults(@yaml[env])) || {}
    # At the time we bind the settings, we also need to run this little piece
    # of magic which allows someone to augment the id with the app name, necessary
    if self['multi_homed'] && app_names.size > 0
      if @local_env.dispatcher_instance_id
        @local_env.dispatcher_instance_id << ":#{app_names.first}"
      else
        @local_env.dispatcher_instance_id = app_names.first
      end
    end

  end
  @settings
end

#sync_startupObject

Configuration option of the same name to indicate that we should connect to RPM synchronously on startup. This means when the agent is loaded it won’t return without trying to set up the server connection at least once which can make startup take longer. Defaults to false.



101
102
103
# File 'lib/new_relic/control/configuration.rb', line 101

def sync_startup
  fetch('sync_startup', false)
end

#use_ssl?Boolean

Returns:

  • (Boolean)


132
133
134
135
# File 'lib/new_relic/control/configuration.rb', line 132

def use_ssl?
  @use_ssl = fetch('ssl', false) unless @use_ssl
  @use_ssl
end

#use_textmate?Boolean

True if we should view files in textmate

Returns:

  • (Boolean)


90
91
92
# File 'lib/new_relic/control/configuration.rb', line 90

def use_textmate?
  fetch('textmate')
end

#validate_seedObject



125
126
127
# File 'lib/new_relic/control/configuration.rb', line 125

def validate_seed
  self['validate_seed'] || ENV['NR_VALIDATE_SEED']
end

#validate_tokenObject



128
129
130
# File 'lib/new_relic/control/configuration.rb', line 128

def validate_token
  self['validate_token'] || ENV['NR_VALIDATE_TOKEN']
end

#verify_certificate?Boolean

Returns:

  • (Boolean)


137
138
139
140
141
142
143
144
145
146
# File 'lib/new_relic/control/configuration.rb', line 137

def verify_certificate?
  unless @verify_certificate
    unless use_ssl?
      @verify_certificate = false
    else
      @verify_certificate = fetch('verify_certificate', false)
    end
  end
  @verify_certificate
end