module NewRelic::Agent::Instrumentation::Memcache::Tracer

Constants

INSTRUMENTATION_NAME
LOCALHOST
MEMCACHED
MULTIGET_METRIC_NAME
SLASH
UNKNOWN

Public Instance Methods

server_for_key_with_newrelic_tracing() { || ... } click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/instrumentation.rb, line 33
def server_for_key_with_newrelic_tracing
  NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)

  yield.tap do |server|
    begin
      if txn = ::NewRelic::Agent::Tracer.current_transaction
        segment = txn.current_segment
        if ::NewRelic::Agent::Transaction::DatastoreSegment === segment
          assign_instance_to(segment, server)
        end
      end
with_newrelic_tracing(operation, *args) { || ... } click to toggle source
# File lib/new_relic/agent/instrumentation/memcache/instrumentation.rb, line 15
def with_newrelic_tracing(operation, *args)
  NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)

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

  begin
    NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
  ensure
    if NewRelic::Agent.config[:capture_memcache_keys]
      segment.notice_nosql_statement("#{operation} #{args.first.inspect}")
    end
    ::NewRelic::Agent::Transaction::Segment.finish(segment)
  end
end