Commit 99881bb7 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Move labels to be initialized in constructor

parent 77e938a8
...@@ -3,7 +3,7 @@ module Gitlab ...@@ -3,7 +3,7 @@ module Gitlab
# Class for tracking timing information about method calls # Class for tracking timing information about method calls
class MethodCall class MethodCall
BASE_LABELS = { module: nil, method: nil }.freeze BASE_LABELS = { module: nil, method: nil }.freeze
attr_reader :real_time, :cpu_time, :call_count attr_reader :real_time, :cpu_time, :call_count, :labels
def self.call_real_duration_histogram def self.call_real_duration_histogram
@call_real_duration_histogram ||= Gitlab::Metrics.histogram( @call_real_duration_histogram ||= Gitlab::Metrics.histogram(
...@@ -31,6 +31,7 @@ module Gitlab ...@@ -31,6 +31,7 @@ module Gitlab
@method_name = method_name @method_name = method_name
@transaction = transaction @transaction = transaction
@name = name @name = name
@labels = { module: @module_name, method: @method_name }
@real_time = 0 @real_time = 0
@cpu_time = 0 @cpu_time = 0
@call_count = 0 @call_count = 0
...@@ -55,10 +56,6 @@ module Gitlab ...@@ -55,10 +56,6 @@ module Gitlab
retval retval
end end
def labels
@labels ||= { module: @module_name, method: @method_name }
end
# Returns a Metric instance of the current method call. # Returns a Metric instance of the current method call.
def to_metric def to_metric
Metric.new( Metric.new(
......
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