Sha256: 01d4d66c7be1c59f3cd92bcaffd1a37c2c53330a7f006f7c3c6f1278c813331c

Contents?: true

Size: 1.83 KB

Versions: 7

Compression:

Stored size: 1.83 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module NewRelic
  module Agent
    module Configuration
      class ServerSource < DottedHash
        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

        # 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.
        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
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
newrelic_rpm-3.6.2.90.beta lib/new_relic/agent/configuration/server_source.rb
newrelic_rpm-3.6.1.88 lib/new_relic/agent/configuration/server_source.rb
newrelic_rpm-3.6.1.87 lib/new_relic/agent/configuration/server_source.rb
newrelic_rpm-3.6.1.86.beta lib/new_relic/agent/configuration/server_source.rb
newrelic_rpm-3.6.1.85.beta lib/new_relic/agent/configuration/server_source.rb
newrelic_rpm-3.6.0.83 lib/new_relic/agent/configuration/server_source.rb
newrelic_rpm-3.6.0.78 lib/new_relic/agent/configuration/server_source.rb