summaryrefslogtreecommitdiff
path: root/lib/gitlab/metrics/transaction.rb
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-09-06 03:19:39 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-11-02 18:11:43 +0100
commitaa25586afea1ef8f909e9ffd7c01d5c9e339b9bc (patch)
tree55208a7a39764b1ff3c3e8397111d411351283e7 /lib/gitlab/metrics/transaction.rb
parent6db3151fa164d65d6176896301166c9883df1fe4 (diff)
downloadgitlab-ce-aa25586afea1ef8f909e9ffd7c01d5c9e339b9bc.tar.gz
Add action tag to more metrics
Diffstat (limited to 'lib/gitlab/metrics/transaction.rb')
-rw-r--r--lib/gitlab/metrics/transaction.rb33
1 files changed, 28 insertions, 5 deletions
diff --git a/lib/gitlab/metrics/transaction.rb b/lib/gitlab/metrics/transaction.rb
index c4d364a08c2..ec298990e5a 100644
--- a/lib/gitlab/metrics/transaction.rb
+++ b/lib/gitlab/metrics/transaction.rb
@@ -87,7 +87,7 @@ module Gitlab
# event_name - The name of the event (e.g. "git_push").
# tags - A set of tags to attach to the event.
def add_event(event_name, tags = {})
- Gitlab::Metrics.counter("gitlab_transaction_event_#{event_name}_total".to_sym, "Transaction event #{event_name}", tags).increment({})
+ self.class.metric_event_counter(event_name, tags).increment(tags.merge({ action: action }))
@metrics << Metric.new(EVENT_SERIES, { count: 1 }, tags, :event)
end
@@ -101,14 +101,12 @@ module Gitlab
end
def increment(name, value, compat = true)
- Gitlab::Metrics.counter("gitlab_transaction_#{name}_total".to_sym, "Transaction counter #{name}", {})
- .increment({}, value) if compat
+ self.class.metric_transaction_counter(name).increment({ action: action }, value) if compat
@values[name] += value
end
def set(name, value, compat = true)
- Gitlab::Metrics.gauge("gitlab_transaction_#{name}".to_sym, "Transaction gauge #{name}", {}, :livesum)
- .set({}, value) if compat
+ self.class.metric_transaction_gauge(name).set({ action: action }, value) if compat
@values[name] = value
end
@@ -144,6 +142,31 @@ module Gitlab
Metrics.submit_metrics(submit_hashes)
end
+
+ private
+
+ def self.metric_event_counter(event_name, tags)
+ @metric_event_counters ||= {}
+ @metric_event_counters[event_name] ||= Gitlab::Metrics.counter(
+ "gitlab_transaction_event_#{event_name}_total".to_sym,
+ "Transaction event #{event_name} counter",
+ tags.merge({ action: nil })
+ )
+ end
+
+ def self.metric_transaction_counter(name)
+ @metric_transaction_counters ||= {}
+ @metric_transaction_counters[name] ||= Gitlab::Metrics.counter(
+ "gitlab_transaction_#{name}_total".to_sym, "Transaction #{name} counter", action: nil
+ )
+ end
+
+ def self.metric_transaction_gauge(name)
+ @metric_transaction_gauges ||= {}
+ @metric_transaction_gauges[name] ||= Gitlab::Metrics.gauge(
+ "gitlab_transaction_#{name}".to_sym, "Transaction gauge #{name}", { action: nil }, :livesum
+ )
+ end
end
end
end