Sha256: 46c1163a5c1cf42bf0a05589469e7d5a2ae3ce9ae091591a357bace3b0931287
Contents?: true
Size: 1.33 KB
Versions: 40
Compression:
Stored size: 1.33 KB
Contents
# frozen_string_literal: true module Datadog module Tracing module Contrib # Registry is a collection of tracing integrations. # @public_api class Registry include Enumerable Entry = Struct.new(:name, :klass, :auto_patch) # @!visibility private def initialize @data = {} @mutex = Mutex.new end # @param name [Symbol] instrumentation name, to be used when activating this integration # @param klass [Object] instrumentation implementation # @param auto_patch [Boolean] is the tracer allowed to automatically patch # the host application with this instrumentation? def add(name, klass, auto_patch = false) @mutex.synchronize do @data[name] = Entry.new(name, klass, auto_patch).freeze end end def each(&block) @mutex.synchronize do @data.each_value(&block) 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 end
Version data entries
40 entries across 40 versions & 2 rubygems