class Object

Constants

CURB_MIN_VERSION
EXCON_MIN_VERSION

TODO: MAJOR VERSION - update min version to 0.56.0

HTTPCLIENT_MIN_VERSION

Public Instance Methods

assign_instance_to(segment, server) click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/instrumentation.rb, line 83
def assign_instance_to(segment, server)
  host = port_path_or_id = nil
  if server.hostname.start_with?(SLASH)
    host = LOCALHOST
    port_path_or_id = server.hostname
  else
    host = server.hostname
    port_path_or_id = server.port
  end
  segment.set_instance_info(host, port_path_or_id)
rescue => e
  ::NewRelic::Agent.logger.debug("Failed to retrieve memcached instance info: #{e.message}")
  segment.set_instance_info(UNKNOWN, UNKNOWN)
end
get_multi_with_newrelic_tracing(method_name) { || ... } click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/instrumentation.rb, line 50
def get_multi_with_newrelic_tracing(method_name)
  NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)

  segment = NewRelic::Agent::Tracer.start_segment(
    name: "Ruby/Memcached/Dalli/#{method_name}"
  )

  begin
    NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
  ensure
    ::NewRelic::Agent::Transaction::Segment.finish(segment)
  end
end
install_excon_instrumentation(excon_version) click to toggle source
# File lib/new_relic/agent/instrumentation/excon.rb, line 36
def install_excon_instrumentation(excon_version)
  require 'new_relic/agent/distributed_tracing/cross_app_tracing'
  require 'new_relic/agent/http_clients/excon_wrappers'

  install_middleware_excon_instrumentation
end
install_middleware_excon_instrumentation() click to toggle source
# File lib/new_relic/agent/instrumentation/excon.rb, line 43
def install_middleware_excon_instrumentation
  NewRelic::Agent.logger.info('Installing middleware-based Excon instrumentation')
  require 'new_relic/agent/instrumentation/excon/middleware'
  defaults = Excon.defaults

  if defaults[:middlewares]
    defaults[:middlewares] << Excon::Middleware::NewRelicCrossAppTracing
  else
    NewRelic::Agent.logger.warn('Did not find :middlewares key in Excon.defaults, skipping Excon instrumentation')
  end
end
install_mongo_command_subscriber() click to toggle source
# File lib/new_relic/agent/instrumentation/mongo.rb, line 25
def install_mongo_command_subscriber
  require 'new_relic/agent/instrumentation/mongodb_command_subscriber'
  Mongo::Monitoring::Global.subscribe(
    Mongo::Monitoring::COMMAND,
    NewRelic::Agent::Instrumentation::MongodbCommandSubscriber.new
  )
end
instrument_with_newrelic(name, payload = {}, &block) click to toggle source
# File lib/new_relic/agent/instrumentation/rails3/action_controller.rb, line 134
def instrument_with_newrelic(name, payload = {}, &block)
  identifier = payload[:identifier]
  scope_name = "View/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.template_metric(identifier)}/Partial"
  trace_execution_scoped(scope_name) do
    instrument_without_newrelic(name, payload, &block)
  end
end
lookup_changelog(changelog) click to toggle source
# File lib/new_relic/recipes/capistrano_legacy.rb, line 52
def lookup_changelog(changelog)
  if !changelog
    logger.debug('Getting log of changes for New Relic Deployment details')
    from_revision = source.next_revision(current_revision)

    if scm == :git
      log_command = "git --no-pager log --no-color --pretty=format:'  * %an: %s' " +
        "--abbrev-commit --no-merges #{previous_revision}..#{real_revision}"
    else
      log_command = "#{source.log(from_revision)}"
    end

    changelog = `#{log_command}`
  end
  changelog
end
lookup_rev(rev) click to toggle source
# File lib/new_relic/recipes/capistrano_legacy.rb, line 69
def lookup_rev(rev)
  if rev.nil?
    rev = source.query_revision(source.head()) do |cmd|
      logger.debug("executing locally: '#{cmd}'")
      `#{cmd}`
    end

    rev = rev[0..6] if scm == :git
  end
  rev
end
render_with_newrelic(context, options) click to toggle source

namespaced helper methods

# File lib/new_relic/agent/instrumentation/rails3/action_controller.rb, line 116
def render_with_newrelic(context, options)
  # This is needed for rails 3.2 compatibility
  @details = extract_details(options) if respond_to?(:extract_details, true)
  # this file can't be found in SimpleCov, need to check test coverage
  identifier = determine_template(options) ? determine_template(options).identifier : nil # rubocop:disable Style/SafeNavigation
  scope_name = "View/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.template_metric(identifier, options)}/Rendering"
  trace_execution_scoped(scope_name) do
    render_without_newrelic(context, options)
  end
end
send_multiget_with_newrelic_tracing(keys) { || ... } click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/instrumentation.rb, line 64
def send_multiget_with_newrelic_tracing(keys)
  NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)

  segment = ::NewRelic::Agent::Tracer.start_datastore_segment(
    product: MEMCACHED,
    operation: MULTIGET_METRIC_NAME
  )

  begin
    assign_instance_to(segment, self)
    NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
  ensure
    if ::NewRelic::Agent.config[:capture_memcache_keys]
      segment.notice_nosql_statement("#{MULTIGET_METRIC_NAME} #{keys.inspect}")
    end
    ::NewRelic::Agent::Transaction::Segment.finish(segment)
  end
end
supported_sequel_version?() click to toggle source
# File lib/new_relic/agent/instrumentation/sequel.rb, line 16
def supported_sequel_version?
  Sequel.const_defined?(:MAJOR) &&
    (Sequel::MAJOR > 3 ||
      Sequel::MAJOR == 3 && Sequel::MINOR >= 37)
end