class OneApm::Configuration::ServerSource

Public Class Methods

new(hash, existing_config = {}) click to toggle source
Calls superclass method OneApm::Support::DottedHash::new
# File lib/one_apm/configuration/server_source.rb, line 7
def initialize(hash, existing_config = {})
  if hash['transaction_tracer']
    transaction_threshold = hash['transaction_tracer']['transaction_threshold']
    if transaction_threshold =~ /apdex_f/i
      # when value is "apdex_f" remove the config and defer to default
      hash['transaction_tracer'].delete('transaction_threshold')
    else
      hash['transaction_tracer']['transaction_threshold'] = transaction_threshold.to_f
    end
  end

  if !hash['browser_monitoring'].nil? && hash['browser_monitoring'].has_key?('transform')
    hash['browser_monitoring']['auto_instrument'] = hash['browser_monitoring']['transform']
  end

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

  if hash['error_collector'] 
    hash['error_collector']['ignore_errors.direction'] = :append
  end

  dotted_hash = OneApm::Support::DottedHash.new(hash).to_hash
  apply_feature_gates(dotted_hash, existing_config)
  
  super(dotted_hash)
end

Public Instance Methods

apply_feature_gates(server_config, existing_config) click to toggle source

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.

# File lib/one_apm/configuration/server_source.rb, line 41
def apply_feature_gates(server_config, existing_config)
  gated_features = {
    :'transaction_tracer.enabled'     => :collect_traces,
    :'slow_sql.enabled'               => :collect_traces,
    :'error_collector.enabled'        => :collect_errors,
    :'analytics_events.enabled'       => :collect_analytics_events,
    :'custom_insights_events.enabled' => :collect_custom_events
  }
  gated_features.each do |feature, gate_key|
    if server_config.has_key?(gate_key)
      allowed_by_server = server_config[gate_key]
      requested_value = ungated_value(feature, server_config, existing_config)
      effective_value = (allowed_by_server && requested_value)
      server_config[feature] = effective_value
    end
  end
end
ungated_value(key, server_config, existing_config) click to toggle source
# File lib/one_apm/configuration/server_source.rb, line 59
def ungated_value(key, server_config, existing_config)
  server_config.has_key?(key) ? server_config[key] : existing_config[key]
end