Class: NewRelic::Agent::Configuration::ServerSource

Inherits:
DottedHash
  • Object
show all
Defined in:
lib/new_relic/agent/configuration/server_source.rb

Instance Method Summary collapse

Methods inherited from DottedHash

#inspect, #to_hash

Constructor Details

#initialize(hash, existing_config = {}) ⇒ ServerSource

Returns a new instance of ServerSource.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/new_relic/agent/configuration/server_source.rb', line 9

def initialize(hash, existing_config={})
  if hash['agent_config']
    if hash['agent_config']['transaction_tracer.transaction_threshold'] =~ /apdex_f/i
      # when value is "apdex_f" remove the config and defer to default
      hash['agent_config'].delete('transaction_tracer.transaction_threshold')
    end
    super(hash.delete('agent_config'))
  end

  if hash['web_transactions_apdex']
    self[:web_transactions_apdex] = hash.delete('web_transactions_apdex')
  end
  apply_feature_gates(hash, existing_config)

  super(hash)
end

Instance Method Details

#apply_feature_gates(hash, existing_config) ⇒ Object

These feature gates are not intended to be bullet-proof, but only to avoid the overhead of collecting and transmitting additional data if the user’s subscription level precludes its use. The server is the ultimate authority regarding subscription levels, so we expect it to do the real enforcement there.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/new_relic/agent/configuration/server_source.rb', line 31

def apply_feature_gates(hash, existing_config)
  gated_features = {
    :'transaction_tracer.enabled' => 'collect_traces',
    :'slow_sql.enabled'           => 'collect_traces',
    :'error_collector.enabled'    => 'collect_errors'
  }
  gated_features.each do |feature, gate_key|
    unless hash[gate_key].nil?
      existing_value = existing_config[feature]
      allowed_by_server = hash[gate_key]
      hash[feature] = (allowed_by_server && existing_value)
    end
  end
end