Sha256: 2463adf627aa0b373dc1fa8e87d2543d5aaad3b2425e9df74a954e5740f7b43b

Contents?: true

Size: 994 Bytes

Versions: 16

Compression:

Stored size: 994 Bytes

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

module NewRelic
  module Agent
    module Instrumentation
      module Roda
        module TransactionNamer
          extend self

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

          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
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
newrelic_rpm-9.17.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.16.1 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.16.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.14.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.13.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.12.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.11.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.10.2 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.10.1 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.10.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.9.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.8.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.7.1 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.7.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb
newrelic_rpm-9.6.0 lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb