Module: NewRelic::Agent::Instrumentation::Roda::TransactionNamer

Extended by:
TransactionNamer
Included in:
TransactionNamer
Defined in:
lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb

Constant Summary collapse

REGEX_MULTIPLE_SLASHES =
%r{^[/^]*(.*?)[/$?]*$}.freeze

Instance Method Summary collapse

Instance Method Details

#transaction_name(request) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb', line 14

def transaction_name(request)
  path = request.path || ::NewRelic::Agent::UNKNOWN_METRIC
  name = path.gsub(REGEX_MULTIPLE_SLASHES, '\1') # remove any rogue slashes
  name = NewRelic::ROOT if name.empty?
  name = "#{request.request_method} #{name}" if request.respond_to?(:request_method)

  name
rescue => e
  ::NewRelic::Agent.logger.debug("#{e.class} : #{e.message} - Error encountered trying to identify Roda transaction name")
  ::NewRelic::Agent::UNKNOWN_METRIC
end