Class: Gitlab::Metrics::WebTransaction

Inherits:
Transaction show all
Defined in:
lib/gitlab/metrics/web_transaction.rb

Constant Summary collapse

CONTROLLER_KEY =
'action_controller.instance'
ENDPOINT_KEY =
'api.endpoint'
ALLOWED_SUFFIXES =
Set.new(%w[json js atom rss xml zip])

Constants inherited from Transaction

Transaction::BASE_LABEL_KEYS, Transaction::EVENT_SERIES, Transaction::FILTERED_LABEL_KEYS, Transaction::SMALL_BUCKETS, Transaction::THREAD_KEY

Instance Attribute Summary

Attributes inherited from Transaction

#method

Instance Method Summary collapse

Methods inherited from Transaction

#add_event, current, #duration, #filter_labels, #increment, #method_call_for, #observe, prometheus_metric, #run, #set, #thread_cpu_duration

Constructor Details

#initialize(env) ⇒ WebTransaction

Returns a new instance of WebTransaction.


10
11
12
13
# File 'lib/gitlab/metrics/web_transaction.rb', line 10

def initialize(env)
  super()
  @env = env
end

Instance Method Details

#labelsObject


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/metrics/web_transaction.rb', line 15

def labels
  return @labels if @labels

  # memoize transaction labels only source env variables were present
  @labels = if @env[CONTROLLER_KEY]
              labels_from_controller || {}
            elsif @env[ENDPOINT_KEY]
              labels_from_endpoint || {}
            end

  @labels || {}
end