Sha256: 6cac628cc1ef11747b5af74ae94197631c1b19b2924abfc5f6a42c4bb02d5464

Contents?: true

Size: 879 Bytes

Versions: 43

Compression:

Stored size: 879 Bytes

Contents

module Datadog
  module Contrib
    # Registry is a collection of integrations.
    class Registry
      include Enumerable

      Entry = Struct.new(:name, :klass, :auto_patch)

      def initialize
        @data = {}
        @mutex = Mutex.new
      end

      def add(name, klass, auto_patch = false)
        @mutex.synchronize do
          @data[name] = Entry.new(name, klass, auto_patch).freeze
        end
      end

      def each
        @mutex.synchronize do
          @data.each { |_, entry| yield(entry) }
        end
      end

      def [](name)
        @mutex.synchronize do
          entry = @data[name]
          entry.klass if entry
        end
      end

      def to_h
        @mutex.synchronize do
          @data.each_with_object({}) do |(_, entry), hash|
            hash[entry.name] = entry.auto_patch
          end
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
ddtrace-0.45.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.44.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.43.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.42.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.41.0 lib/ddtrace/contrib/registry.rb
ls-trace-0.2.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.40.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.39.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.38.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.37.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.36.0 lib/ddtrace/contrib/registry.rb
ls-trace-0.1.2 lib/ddtrace/contrib/registry.rb
ddtrace-0.35.2 lib/ddtrace/contrib/registry.rb
ddtrace-0.35.1 lib/ddtrace/contrib/registry.rb
ddtrace-0.35.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.34.2 lib/ddtrace/contrib/registry.rb
ddtrace-0.34.1 lib/ddtrace/contrib/registry.rb
ddtrace-0.34.0 lib/ddtrace/contrib/registry.rb
ddtrace-0.33.1 lib/ddtrace/contrib/registry.rb
ddtrace-0.33.0 lib/ddtrace/contrib/registry.rb