Method: NewRelic::Agent::MethodTracer::ClassMethods::AddMethodTracer#_nr_validate_method_tracer_options

Defined in:
lib/new_relic/agent/method_tracer.rb

#_nr_validate_method_tracer_options(method_name, options) ⇒ Object

Checks the provided options to make sure that they make sense. Raises an error if the options are incorrect to assist with debugging, so that errors occur at class construction time rather than instrumentation run time



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/new_relic/agent/method_tracer.rb', line 114

def _nr_validate_method_tracer_options(method_name, options)
  unless options.is_a?(Hash)
    raise TypeError.new("Error adding method tracer to #{method_name}: provided options must be a Hash")
  end

  unrecognized_keys = options.keys - ALLOWED_KEYS
  if unrecognized_keys.any?
    raise "Unrecognized options when adding method tracer to #{method_name}: " +
      unrecognized_keys.join(', ')
  end

  options = DEFAULT_SETTINGS.merge(options)
  unless options[:push_scope] || options[:metric]
    raise "Can't add a tracer where push_scope is false and metric is false"
  end

  options
end