Commit cc7997d8 authored by Pawel Chojnacki's avatar Pawel Chojnacki

More parsable labels in method performance measurements

parent 43a9777e
...@@ -8,7 +8,7 @@ module Gitlab ...@@ -8,7 +8,7 @@ module Gitlab
@call_real_duration_histogram ||= Gitlab::Metrics.histogram( @call_real_duration_histogram ||= Gitlab::Metrics.histogram(
:gitlab_method_call_real_duration_seconds, :gitlab_method_call_real_duration_seconds,
'Method calls real duration', 'Method calls real duration',
{ action: nil, call_name: nil }, Transaction::BASE_LABELS.merge({ call_name: nil }),
[0.1, 0.2, 0.5, 1, 2, 5, 10] [0.1, 0.2, 0.5, 1, 2, 5, 10]
) )
end end
...@@ -17,7 +17,7 @@ module Gitlab ...@@ -17,7 +17,7 @@ module Gitlab
@call_duration_histogram ||= Gitlab::Metrics.histogram( @call_duration_histogram ||= Gitlab::Metrics.histogram(
:gitlab_method_call_cpu_duration_seconds, :gitlab_method_call_cpu_duration_seconds,
'Method calls cpu duration', 'Method calls cpu duration',
{ action: nil, call_name: nil }, Transaction::BASE_LABELS.merge({ call_name: nil }),
[0.1, 0.2, 0.5, 1, 2, 5, 10] [0.1, 0.2, 0.5, 1, 2, 5, 10]
) )
end end
...@@ -25,8 +25,8 @@ module Gitlab ...@@ -25,8 +25,8 @@ module Gitlab
# name - The full name of the method (including namespace) such as # name - The full name of the method (including namespace) such as
# `User#sign_in`. # `User#sign_in`.
# #
def initialize(name, action) def initialize(name, transaction)
@action = action @transaction = transaction
@name = name @name = name
@real_time = 0 @real_time = 0
@cpu_time = 0 @cpu_time = 0
...@@ -44,8 +44,8 @@ module Gitlab ...@@ -44,8 +44,8 @@ module Gitlab
@call_count += 1 @call_count += 1
if above_threshold? if above_threshold?
self.class.call_real_duration_histogram.observe({ call_name: @name, action: @action }, @real_time / 1000.0) self.class.call_real_duration_histogram.observe(@transaction.labels.merge({ call_name: @name }), @real_time / 1000.0)
self.class.call_cpu_duration_histogram.observe({ call_name: @name, action: @action }, @cpu_time / 1000.0) self.class.call_cpu_duration_histogram.observe(@transaction.labels.merge({ call_name: @name }), @cpu_time / 1000.0)
end end
retval retval
......
...@@ -107,7 +107,7 @@ module Gitlab ...@@ -107,7 +107,7 @@ module Gitlab
# Returns a MethodCall object for the given name. # Returns a MethodCall object for the given name.
def method_call_for(name) def method_call_for(name)
unless method = @methods[name] unless method = @methods[name]
@methods[name] = method = MethodCall.new(name, action) @methods[name] = method = MethodCall.new(name, transaction)
end end
method method
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment