Sha256: 8fdb35b8319cfe7704746a7e474cf210e14b1c153d87a3f48bacf7c160151423

Contents?: true

Size: 915 Bytes

Versions: 3

Compression:

Stored size: 915 Bytes

Contents

module AllscriptsUnityClient

  # A mixin to provide support for New Relic instrumentation.
  module NewRelicSupport

    # Mixin NewRelic::Agent::MethodTracer for a given object.
    #
    # instance:: The object to use as the target for the mixin.
    def self.enable_method_tracer(instance)
      class << instance
        if !respond_to?(:trace_execution_scoped) && !respond_to?(:add_method_tracer)
          extend ::NewRelic::Agent::MethodTracer
        end
      end
    end

    # If a given class supports New Relic trace_execution_scoped, then
    # run the given block using that method.
    #
    # klass:: The target class.
    # scope:: A New Relic scope string.
    def self.trace_execution_scoped_if_available(klass, scope)
      if klass.respond_to?(:trace_execution_scoped)
        klass.trace_execution_scoped(scope, &Proc.new)
      else
        yield if block_given?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
allscripts_unity_client-2.2.4 lib/allscripts_unity_client/new_relic_support.rb
allscripts_unity_client-2.2.3 lib/allscripts_unity_client/new_relic_support.rb
allscripts_unity_client-2.2.2 lib/allscripts_unity_client/new_relic_support.rb