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

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

Instance Method Summary collapse

Instance Method Details

#transaction_name(request) ⇒ Object



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

def transaction_name(request)
  path = request.path || ::NewRelic::Agent::UNKNOWN_METRIC
  name = path.gsub(REGEX_MULTIPLE_SLASHES, '\1') # remove any rogue slashes
  name = 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