summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2019-08-29 13:51:00 +0200
committerAndreas Brandl <abrandl@gitlab.com>2019-08-30 07:58:33 +0200
commit1003cd92cbaf9df12bf01b85c16c8dabdb1a8b72 (patch)
treec1ba4f66607ad99215faeb8271dfcbe900ad4cc5
parent739d6a5ad3ac3756d89d6d07fec5fb876aa333d6 (diff)
downloadgitlab-ce-1003cd92cbaf9df12bf01b85c16c8dabdb1a8b72.tar.gz
Add method call count instrumentation
-rw-r--r--app/models/concerns/routable.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb
index 115c3ce2f91..01b853d413c 100644
--- a/app/models/concerns/routable.rb
+++ b/app/models/concerns/routable.rb
@@ -59,12 +59,23 @@ module Routable
def where_full_path_in(paths)
return none if paths.empty?
+ increment_full_path_in_counter
+
wheres = paths.map do |path|
"(LOWER(routes.path) = LOWER(#{connection.quote(path)}))"
end
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')
+
+ @counter.increment
+ rescue
+ # ignore the error
+ end
end
def full_name