Module: Gitlab::RuggedInstrumentation

Defined in:
lib/gitlab/rugged_instrumentation.rb

Class Method Summary collapse

Class Method Details

.active?Boolean

Returns:

  • (Boolean)

28
29
30
# File 'lib/gitlab/rugged_instrumentation.rb', line 28

def self.active?
  SafeRequestStore.active?
end

.add_call_details(details) ⇒ Object


32
33
34
35
36
37
# File 'lib/gitlab/rugged_instrumentation.rb', line 32

def self.add_call_details(details)
  return unless Gitlab::PerformanceBar.enabled_for_request?

  Gitlab::SafeRequestStore[:rugged_call_details] ||= []
  Gitlab::SafeRequestStore[:rugged_call_details] << details
end

.add_query_time(duration) ⇒ Object


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

def self.add_query_time(duration)
  SafeRequestStore[:rugged_query_time] ||= 0
  SafeRequestStore[:rugged_query_time] += duration
end

.increment_query_countObject


23
24
25
26
# File 'lib/gitlab/rugged_instrumentation.rb', line 23

def self.increment_query_count
  SafeRequestStore[:rugged_call_count] ||= 0
  SafeRequestStore[:rugged_call_count] += 1
end

.list_call_detailsObject


39
40
41
42
43
# File 'lib/gitlab/rugged_instrumentation.rb', line 39

def self.list_call_details
  return [] unless Gitlab::PerformanceBar.enabled_for_request?

  Gitlab::SafeRequestStore[:rugged_call_details] || []
end

.query_countObject


19
20
21
# File 'lib/gitlab/rugged_instrumentation.rb', line 19

def self.query_count
  SafeRequestStore[:rugged_call_count] ||= 0
end

.query_timeObject


5
6
7
8
# File 'lib/gitlab/rugged_instrumentation.rb', line 5

def self.query_time
  query_time = SafeRequestStore[:rugged_query_time] || 0
  query_time.round(Gitlab::InstrumentationHelper::DURATION_PRECISION)
end

.query_time_msObject


15
16
17
# File 'lib/gitlab/rugged_instrumentation.rb', line 15

def self.query_time_ms
  (self.query_time * 1000).round(2)
end