Module: SignalFx::Tracing::Instrumenter::PG

Defined in:
lib/signalfx/tracing/instrumentation/pg.rb

Class Method Summary collapse

Class Method Details

.instrument(opts = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/signalfx/tracing/instrumentation/pg.rb', line 15

def instrument(opts = {})
  return if @instrumented

  # check for required gems
  begin
    require 'pg'
  rescue LoadError
    return
  end

  begin
    require 'pg/instrumentation'
  rescue LoadError => e
    @logger.error { e.message }
    return
  end

  tracer = opts.fetch(:tracer, OpenTracing.global_tracer)

  ::PG::Instrumentation.instrument(tracer: tracer) if !@instrumented
  @instrumented = true
end