Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahramadan committed Jul 26, 2023
1 parent 64b6ac9 commit 31a1ee2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/new_relic/agent/instrumentation/roda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

depends_on do
defined?(Roda) &&
Roda::RodaVersion >= '3.19.0' &&
Gem::Version.new(Roda::RodaVersion) >= '3.19.0' &&
Roda::RodaPlugins::Base::ClassMethods.private_method_defined?(:build_rack_app) &&
Roda::RodaPlugins::Base::InstanceMethods.method_defined?(:_roda_handle_main_route)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/new_relic/agent/instrumentation/roda/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def rack_request_params

def _roda_handle_main_route_with_tracing(*args)
request_params = rack_request_params
filtered_params = ::NewRelic::Agent::ParameterFiltering::apply_filters(request.env, request_params || {})
filtered_params = ::NewRelic::Agent::ParameterFiltering::apply_filters(request.env, request_params ||
NewRelic::EMPTY_HASH)
name = TransactionNamer.initial_transaction_name(request)

perform_action_with_newrelic_trace(:category => :roda,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ def initial_transaction_name(request)
end

ROOT = '/'.freeze
REGEX_MUTIPLE_SLASHES = %r{^[/^\\A]*(.*?)[/\$\?\\z]*$}.freeze

def transaction_name(path, request)
verb = http_verb(request)
path = request.path if request.path
name = path.gsub(%r{^[/^\\A]*(.*?)[/\$\?\\z]*$}, '\1') # remove any rouge slashes
name = path.gsub(REGEX_MUTIPLE_SLASHES, '\1') # remove any rogue slashes
name = ROOT if name.empty?
name = "#{verb} #{name}" unless verb.nil?

Expand Down

0 comments on commit 31a1ee2

Please sign in to comment.