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

Class Method Summary collapse

Class Method Details

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


52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 52

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


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

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

.detail_storeObject


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

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

.get_request_countObject


29
30
31
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 29

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

.increment_request_countObject


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

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

.query_timeObject


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

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