Sha256: 57014b36f720662c8878aa646e0158cd18f1b74677f721cf79b513993f671584

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module Datadog
  module Contrib
    # Namespace for `resque` integration
    module Resque
      SERVICE = 'resque'.freeze

      class << self
        # Globally-acccesible reference for pre-forking optimization
        attr_accessor :sync_writer
      end

      # Patcher for Resque integration - sets up the pin for the integration
      module Patcher
        include Base
        register_as :resque, auto_patch: true

        @patched = false

        class << self
          def patch
            return @patched if patched? || !defined?(::Resque)

            require 'ddtrace/ext/app_types'

            add_pin
            @patched = true
          rescue => e
            Tracer.log.error("Unable to apply Resque integration: #{e}")
            @patched
          end

          def patched?
            @patched
          end

          private

          def add_pin
            Pin.new(SERVICE, app_type: Ext::AppTypes::WORKER).tap do |pin|
              pin.onto(::Resque)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddtrace-0.10.0 lib/ddtrace/contrib/resque/patcher.rb