Sha256: 06a1d558eee5909d2030938c46d8b9cc20e33b6dd8cbf21c92f3c30eaa06c727

Contents?: true

Size: 1.64 KB

Versions: 35

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module Datadog
  module Tracing
    module Contrib
      # Defines registerable behavior for integrations
      module Registerable
        def self.included(base)
          base.extend(ClassMethods)
          base.include(InstanceMethods)
        end

        # Class methods for registerable behavior
        # @public_api
        module ClassMethods
          # Registers this integration in the global tracer registry.
          # Once registered, this integration can be activated with:
          #
          # ```
          # Datadog.configure do |c|
          #   c.tracing.instrument :name
          # end
          # ```
          #
          # @param [Symbol] name integration name. Used during activation.
          # @param [Datadog::Tracing::Contrib::Registry] registry a custom registry.
          #        Defaults to the global tracing registry.
          # @param [Boolean] auto_patch will this integration be activated during
          #   {file:docs/AutoInstrumentation.md Auto Instrumentation}?
          # @param [Hash] options additional keyword options passed to the initializer of
          #   a custom {Registerable} instrumentation
          # @see Datadog::Tracing::Contrib::Integration
          def register_as(name, registry: Contrib::REGISTRY, auto_patch: false, **options)
            registry.add(name, new(name, **options), auto_patch)
          end
        end

        # Instance methods for registerable behavior
        module InstanceMethods
          attr_reader \
            :name

          def initialize(name, **options)
            @name = name
          end
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
datadog-2.9.0 lib/datadog/tracing/contrib/registerable.rb
datadog-2.8.0 lib/datadog/tracing/contrib/registerable.rb
datadog-2.7.1 lib/datadog/tracing/contrib/registerable.rb
datadog-2.7.0 lib/datadog/tracing/contrib/registerable.rb
datadog-2.6.0 lib/datadog/tracing/contrib/registerable.rb
datadog-2.5.0 lib/datadog/tracing/contrib/registerable.rb
datadog-2.4.0 lib/datadog/tracing/contrib/registerable.rb
datadog-2.3.0 lib/datadog/tracing/contrib/registerable.rb
datadog-2.2.0 lib/datadog/tracing/contrib/registerable.rb
ddtrace-1.23.3 lib/datadog/tracing/contrib/registerable.rb
ddtrace-1.23.2 lib/datadog/tracing/contrib/registerable.rb
datadog-2.1.0 lib/datadog/tracing/contrib/registerable.rb
datadog-2.0.0 lib/datadog/tracing/contrib/registerable.rb
ddtrace-1.23.1 lib/datadog/tracing/contrib/registerable.rb
datadog-2.0.0.beta2 lib/datadog/tracing/contrib/registerable.rb
ddtrace-1.22.0 lib/datadog/tracing/contrib/registerable.rb
datadog-2.0.0.beta1 lib/datadog/tracing/contrib/registerable.rb
ddtrace-1.21.1 lib/datadog/tracing/contrib/registerable.rb
ddtrace-1.21.0 lib/datadog/tracing/contrib/registerable.rb
ddtrace-1.20.0 lib/datadog/tracing/contrib/registerable.rb