Module: Gitlab::Instrumentation::ElasticsearchTransportInterceptor

Defined in:
lib/gitlab/instrumentation/elasticsearch_transport.rb

Instance Method Summary collapse

Instance Method Details

#perform_request(method, path, params = {}, body = nil, headers = nil) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/instrumentation/elasticsearch_transport.rb', line 8

def perform_request(method, path, params = {}, body = nil, headers = nil)
  start = Time.now
  headers = (headers || {})
    .reverse_merge({ 'X-Opaque-Id': Labkit::Correlation::CorrelationId.current_or_new_id })
  super
ensure
  if ::Gitlab::SafeRequestStore.active?
    duration = (Time.now - start)

    ::Gitlab::Instrumentation::ElasticsearchTransport.increment_request_count
    ::Gitlab::Instrumentation::ElasticsearchTransport.add_duration(duration)
    ::Gitlab::Instrumentation::ElasticsearchTransport.add_call_details(duration, method, path, params, body)
  end
end