diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2019-08-30 11:50:26 +0200 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2019-08-30 11:50:26 +0200 |
commit | edde1b708a6a605185a6dde73550b9f45e673371 (patch) | |
tree | 6d5e9379b868b3802ad016538c2572342e61a02d | |
parent | 1003cd92cbaf9df12bf01b85c16c8dabdb1a8b72 (diff) | |
download | gitlab-ce-edde1b708a6a605185a6dde73550b9f45e673371.tar.gz |
Add another counter to calculate method call ratioab-routable-two-step-search
We should see the ratio drop down when enabling the Feature.
Recommendation by @andrewn
-rw-r--r-- | app/models/concerns/routable.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb index 01b853d413c..3a486632800 100644 --- a/app/models/concerns/routable.rb +++ b/app/models/concerns/routable.rb @@ -33,6 +33,8 @@ module Routable # # Returns a single object, or nil. def find_by_full_path(path, follow_redirects: false) + increment_counter(:routable_find_by_full_path, 'Number of calls to Routable.find_by_full_path') + if Feature.enabled?(:routable_two_step_lookup) # Case sensitive match first (it's cheaper and the usual case) # If we didn't have an exact match, we perform a case insensitive search @@ -59,7 +61,7 @@ module Routable def where_full_path_in(paths) return none if paths.empty? - increment_full_path_in_counter + increment_counter(:routable_where_full_path_in, 'Number of calls to Routable.where_full_path_in') wheres = paths.map do |path| "(LOWER(routes.path) = LOWER(#{connection.quote(path)}))" @@ -68,11 +70,11 @@ module Routable joins(:route).where(wheres.join(' OR ')) end - # Temporary instrumentation of method calls for .where_full_path_in - def increment_full_path_in_counter - @counter ||= Gitlab::Metrics.counter(:routable_caseinsensitive_lookup_calls, 'Number of calls to Routable.where_full_path_in') + # Temporary instrumentation of method calls + def increment_counter(counter, description) + @counters[counter] ||= Gitlab::Metrics.counter(counter, description) - @counter.increment + @counters[counter].increment rescue # ignore the error end |