diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-08-29 15:01:37 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-11-02 20:10:57 +0300 |
commit | f464adaaf6e463e148a1b74d8f1f8280a49594c3 (patch) | |
tree | 32d259c381c5bcbec773e50cb722f794388eec27 /lib/gitlab | |
parent | 3b1464803bd9b72eb00ca9e70623a647550794cf (diff) |
Remove transaction tags and map transaction metrics to prometheus
+ clean transaction metrics
+ Gemfile.lock file update
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/metrics/influx_db.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/metrics/transaction.rb | 39 |
2 files changed, 24 insertions, 25 deletions
diff --git a/lib/gitlab/metrics/influx_db.rb b/lib/gitlab/metrics/influx_db.rb index 7b06bb953aa..1e3db4eb8b4 100644 --- a/lib/gitlab/metrics/influx_db.rb +++ b/lib/gitlab/metrics/influx_db.rb @@ -109,16 +109,6 @@ module Gitlab retval end - # Adds a tag to the current transaction (if any) - # - # name - The name of the tag to add. - # value - The value of the tag. - def tag_transaction(name, value) - trans = current_transaction - - trans&.add_tag(name, value) - end - # Sets the action of the current transaction (if any) # # action - The name of the action. diff --git a/lib/gitlab/metrics/transaction.rb b/lib/gitlab/metrics/transaction.rb index 2a4578aa6e4..da1f44b1eab 100644 --- a/lib/gitlab/metrics/transaction.rb +++ b/lib/gitlab/metrics/transaction.rb @@ -40,6 +40,24 @@ module Gitlab @memory_after - @memory_before end + def self.metric_transaction_duration_milliseconds + @metrics_transaction_duration_milliseconds ||= Gitlab::Metrics.histogram( + :gitlab_transaction_duration_milliseconds, + 'Method duration milliseconds', + {}, + [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000] + ) + end + + def self.metric_transaction_allocated_memory_bytes + @metric_transaction_allocated_memory_bytes ||= Gitlab::Metrics.histogram( + :gitlab_transaction_allocated_memory_bytes, + 'Method duration milliseconds', + {}, + [1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 5000000] + ) + end + def run Thread.current[THREAD_KEY] = self @@ -51,10 +69,8 @@ module Gitlab @memory_after = System.memory_usage @finished_at = System.monotonic_time - Gitlab::Metrics.histogram("gitlab_method_duration_seconds".to_sym, "Method duration seconds", @tags).observe({}, ) - - self.class.prometheus_gauge(:duration).set(@tags, duration) - self.class.prometheus_gauge(:allocated_memory).set(@tags, allocated_memory) + self.class.metric_transaction_duration_milliseconds.observe({}, duration) + self.class.metric_transaction_allocated_memory_bytes.observe({}, allocated_memory) Thread.current[THREAD_KEY] = nil end @@ -71,8 +87,8 @@ 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_event_#{event_name}".to_sym, "Event #{event_name}", tags).increment({}) - @metrics << Metric.new(EVENT_SERIES, { count: 1 }, labels, :event) + Gitlab::Metrics.counter("gitlab_transaction_event_#{event_name}_total".to_sym, "Transaction event #{event_name}", tags).increment({}) + @metrics << Metric.new(EVENT_SERIES, { count: 1 }, tags, :event) end # Returns a MethodCall object for the given name. @@ -85,17 +101,15 @@ module Gitlab end def increment(name, value) + Gitlab::Metrics.counter("gitlab_transaction_#{name}_total".to_sym, "Transaction counter #{name}", {}).increment({}, value) @values[name] += value end def set(name, value) + Gitlab::Metrics.gauge("gitlab_transaction_#{name}".to_sym, "Transaction gauge #{name}", {}, :livesum).set({}, value) @values[name] = value end - def add_tag(key, value) - @tags[key] = value - end - def finish track_self submit @@ -106,16 +120,11 @@ module Gitlab @values.each do |name, value| values[name] = value - self.class.prometheus_gauge(name).set(@tags, value) end add_metric('transactions', values, @tags) end - def self.prometheus_gauge(name) - Gitlab::Metrics.gauge("gitlab_transaction_#{name}".to_sym, "Gitlab Transaction #{name}") - end - def submit submit = @metrics.dup |