Sha256: b7143f9118e07339a7f8c7c8fd5e701f947d70bc94dd2e46aece714b13d01290

Contents?: true

Size: 1.41 KB

Versions: 17

Compression:

Stored size: 1.41 KB

Contents

require 'ddtrace/ext/app_types'
require 'ddtrace/contrib/racecar/events'

module Datadog
  module Contrib
    module Racecar
      # Provides instrumentation for `racecar` through ActiveSupport instrumentation signals
      module Patcher
        include Base

        register_as :racecar
        option :service_name, default: 'racecar'
        option :tracer, default: Datadog.tracer do |value|
          (value || Datadog.tracer).tap do |v|
            # Make sure to update tracers of all subscriptions
            Events.subscriptions.each do |subscription|
              subscription.tracer = v
            end
          end
        end

        class << self
          def patch
            return patched? if patched? || !compatible?

            # Subscribe to Racecar events
            Events.subscribe!

            # Set service info
            configuration[:tracer].set_service_info(
              configuration[:service_name],
              'racecar',
              Ext::AppTypes::WORKER
            )

            @patched = true
          end

          def patched?
            return @patched if defined?(@patched)
            @patched = false
          end

          private

          def configuration
            Datadog.configuration[:racecar]
          end

          def compatible?
            defined?(::Racecar) && defined?(::ActiveSupport::Notifications)
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ddtrace-0.16.1 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.15.0.internaltracinfeature1 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.16.0 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.14.2.disableprotocolversion4 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.15.0 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.14.2.withoutpriorityparsing1 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.14.2 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.14.1 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.15.0.beta1 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.14.0 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.14.0.rc1 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.13.2 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.14.0.beta2 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.14.0.beta1 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.13.1 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.13.0 lib/ddtrace/contrib/racecar/patcher.rb
ddtrace-0.13.0.beta1 lib/ddtrace/contrib/racecar/patcher.rb