Class: Gitlab::Instrumentation::ElasticsearchTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/instrumentation/elasticsearch_transport.rb

Constant Summary collapse

ELASTICSEARCH_REQUEST_COUNT =
:elasticsearch_request_count
ELASTICSEARCH_CALL_DURATION =
:elasticsearch_call_duration
ELASTICSEARCH_CALL_DETAILS =
:elasticsearch_call_details
ELASTICSEARCH_TIMED_OUT_COUNT =
:elasticsearch_timed_out_count

Class Method Summary collapse

Class Method Details

.add_call_details(duration, method, path, params, body) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 67

def self.add_call_details(duration, method, path, params, body)
  return unless Gitlab::PerformanceBar.enabled_for_request?

  detail_store << {
    method: method,
    path: path,
    params: params,
    body: body,
    duration: duration,
    backtrace: ::Gitlab::BacktraceCleaner.clean_backtrace(caller)
  }
end

.add_duration(duration) ⇒ Object



53
54
55
56
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 53

def self.add_duration(duration)
  ::Gitlab::SafeRequestStore[ELASTICSEARCH_CALL_DURATION] ||= 0
  ::Gitlab::SafeRequestStore[ELASTICSEARCH_CALL_DURATION] += duration
end

.detail_storeObject



44
45
46
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 44

def self.detail_store
  ::Gitlab::SafeRequestStore[ELASTICSEARCH_CALL_DETAILS] ||= []
end

.get_request_countObject



35
36
37
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 35

def self.get_request_count
  ::Gitlab::SafeRequestStore[ELASTICSEARCH_REQUEST_COUNT] || 0
end

.get_timed_out_countObject



63
64
65
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 63

def self.get_timed_out_count
  ::Gitlab::SafeRequestStore[ELASTICSEARCH_TIMED_OUT_COUNT] || 0
end

.increment_request_countObject



39
40
41
42
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 39

def self.increment_request_count
  ::Gitlab::SafeRequestStore[ELASTICSEARCH_REQUEST_COUNT] ||= 0
  ::Gitlab::SafeRequestStore[ELASTICSEARCH_REQUEST_COUNT] += 1
end

.increment_timed_out_countObject



58
59
60
61
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 58

def self.increment_timed_out_count
  ::Gitlab::SafeRequestStore[ELASTICSEARCH_TIMED_OUT_COUNT] ||= 0
  ::Gitlab::SafeRequestStore[ELASTICSEARCH_TIMED_OUT_COUNT] += 1
end

.query_timeObject



48
49
50
51
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 48

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