module SignalFx::Tracing::Instrumenter::PG

Public Class Methods

instrument(opts = {}) click to toggle source
# 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