Module: NewRelic::Manticore

Defined in:
lib/new_relic/manticore/instrumentation.rb,
lib/new_relic/manticore/wrapped_request.rb,
lib/new_relic/manticore/wrapped_response.rb

Defined Under Namespace

Classes: WrappedRequest, WrappedResponse

Class Method Summary collapse

Class Method Details

.create_segment?Boolean

We do not want to create a segment if there is no newrelic transaction or if we are inside a database segment.

An external call segment inside a database segment would deduct the time needed in manticore from the database call, which we want to be the total time needed for the database operation

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
# File 'lib/new_relic/manticore/instrumentation.rb', line 19

def self.create_segment?
  state = NewRelic::Agent::TransactionState.tl_get
  return false unless state&.current_transaction

  return true unless state.current_transaction.current_segment

  !state.current_transaction.current_segment.is_a?(
    ::NewRelic::Agent::Transaction::DatastoreSegment
  )
end