Module: NewRelic::Agent::Instrumentation::OpenSearch

Included in:
OpenSearch::Prepend
Defined in:
lib/new_relic/agent/instrumentation/opensearch/instrumentation.rb

Defined Under Namespace

Modules: Chain, Prepend

Constant Summary collapse

PRODUCT_NAME =
'OpenSearch'
OPERATION =
'perform_request'
OPERATION_PATTERN =
%r{/lib/opensearch/api/(?!.+#{OPERATION})}
INSTANCE_METHOD_PATTERN =
/:in (?:`|')(?:.+#)?([^']+)'\z/
INSTRUMENTATION_NAME =
NewRelic::Agent.base_name(name)

Instance Method Summary collapse

Instance Method Details

#perform_request_with_tracing(_method, _path, params = NewRelic::EMPTY_HASH, body = nil, _headers = nil, _opts = nil, &_block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/new_relic/agent/instrumentation/opensearch/instrumentation.rb', line 13

def perform_request_with_tracing(_method, _path, params = NewRelic::EMPTY_HASH, body = nil, _headers = nil, _opts = nil, &_block)
  return yield unless NewRelic::Agent::Tracer.tracing_enabled?

  segment = NewRelic::Agent::Tracer.start_datastore_segment(
    product: PRODUCT_NAME,
    operation: nr_operation || OPERATION,
    host: nr_hosts[:host],
    port_path_or_id: nr_hosts[:port],
    database_name: nr_cluster_name
  )
  begin
    NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
  ensure
    if segment
      segment.notice_nosql_statement(nr_reported_query(body || params))
      segment.finish
    end
  end
end