Sha256: 23e0e6f176da8792da60131fbf025c00aed63c332dd55a7fb8e1fbf96b853a31

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

require_relative '../ext/settings'

module Datadog
  module CI
    module Configuration
      # Adds CI behavior to Datadog trace settings
      module Settings
        def self.extended(base)
          base = base.singleton_class unless base.is_a?(Class)
          add_settings!(base)
        end

        def self.add_settings!(base)
          base.class_eval do
            settings :ci do
              option :enabled do |o|
                o.default { env_to_bool(CI::Ext::Settings::ENV_MODE_ENABLED, false) }
                o.lazy
              end

              # DEV: Alias to Datadog::Tracing::Contrib::Extensions::Configuration::Settings#instrument.
              # DEV: Should be removed when CI implement its own `c.ci.instrument`.
              define_method(:instrument) do |integration_name, options = {}, &block|
                Datadog.configuration.tracing.instrument(integration_name, options, &block)
              end

              # DEV: Alias to Datadog::Tracing::Contrib::Extensions::Configuration::Settings#instrument.
              # DEV: Should be removed when CI implement its own `c.ci[]`.
              define_method(:[]) do |integration_name, key = :default|
                Datadog.configuration.tracing[integration_name, key]
              end

              # TODO: Deprecate in the next major version, as `instrument` better describes this method's purpose
              alias_method :use, :instrument

              option :trace_flush do |o|
                o.default { nil }
                o.lazy
              end

              option :writer_options do |o|
                o.default { {} }
                o.lazy
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddtrace-1.10.1 lib/datadog/ci/configuration/settings.rb
ddtrace-1.10.0 lib/datadog/ci/configuration/settings.rb