summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Kochie <bjk@gitlab.com>2019-09-03 16:04:13 +0200
committerBen Kochie <bjk@gitlab.com>2019-09-05 09:14:56 +0200
commit56c01f62d5c5509f63aa46547cf90276a360775e (patch)
treeef51a355d6df93eb40a324e89f0bca0ed22ce0ea
parent97092fbb48c0511f03624a0221c5f7109a796e3d (diff)
downloadgitlab-ce-bjk/routable_counter.tar.gz
Adjust routable metricbjk/routable_counter
* Define the counter once. * Make metric name follow Prometheus naming conventions. * Add label for call method.
-rw-r--r--app/models/concerns/routable.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb
index 07d22641a0a..8b011bca72c 100644
--- a/app/models/concerns/routable.rb
+++ b/app/models/concerns/routable.rb
@@ -33,7 +33,7 @@ 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')
+ routable_calls_counter.increment(method: 'find_by_full_path')
if Feature.enabled?(:routable_two_step_lookup)
# Case sensitive match first (it's cheaper and the usual case)
@@ -61,7 +61,7 @@ module Routable
def where_full_path_in(paths)
return none if paths.empty?
- increment_counter(:routable_where_full_path_in, 'Number of calls to Routable.where_full_path_in')
+ routable_calls_counter.increment(method: 'where_full_path_in')
wheres = paths.map do |path|
"(LOWER(routes.path) = LOWER(#{connection.quote(path)}))"
@@ -71,12 +71,8 @@ module Routable
end
# Temporary instrumentation of method calls
- def increment_counter(counter, description)
- @counters[counter] ||= Gitlab::Metrics.counter(counter, description)
-
- @counters[counter].increment
- rescue
- # ignore the error
+ def routable_calls_counter
+ @routable_calls_counter ||= Gitlab::Metrics.counter(:gitlab_routable_calls_total, 'Number of calls to Routable by method')
end
end