Sha256: 252c13c12136c4d229865c08a0aea52330969bc91ad6db954857533ffd094ae6

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

require 'ddtrace/environment'
require 'ddtrace/configuration/options'

module Datadog
  module Contrib
    module Configuration
      # Common settings for all integrations
      class Settings
        extend Datadog::Environment::Helpers
        include Datadog::Configuration::Options

        option :service_name
        option :tracer,
               default: -> { Datadog.tracer },
               lazy: true
        option :analytics_enabled, default: false
        option :analytics_sample_rate, default: 1.0

        def initialize(options = {})
          configure(options)
        end

        def configure(options = {})
          self.class.options.dependency_order.each do |name|
            self[name] = options.fetch(name, self[name])
          end

          yield(self) if block_given?
        end

        def [](name)
          respond_to?(name) ? send(name) : get_option(name)
        end

        def []=(name, value)
          respond_to?("#{name}=") ? send("#{name}=", value) : set_option(name, value)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ddtrace-0.26.1 lib/ddtrace/contrib/configuration/settings.rb
ddtrace-0.28.0 lib/ddtrace/contrib/configuration/settings.rb
ddtrace-0.27.0 lib/ddtrace/contrib/configuration/settings.rb
ddtrace-0.26.0 lib/ddtrace/contrib/configuration/settings.rb
ddtrace-0.25.1 lib/ddtrace/contrib/configuration/settings.rb
ddtrace-0.25.0 lib/ddtrace/contrib/configuration/settings.rb
ddtrace-0.24.0 lib/ddtrace/contrib/configuration/settings.rb
ddtrace-0.23.3 lib/ddtrace/contrib/configuration/settings.rb