Class: Datadog::Tracing::Contrib::Registry

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Enumerable[untyped]
Defined in:
lib/datadog/tracing/contrib/registry.rb,
sig/datadog/tracing/contrib/registry.rbs

Overview

Registry is a collection of tracing integrations.

Constant Summary collapse

Entry =

Returns:

  • (Object)

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Registry

Returns a new instance of Registry.



14
15
16
17
# File 'lib/datadog/tracing/contrib/registry.rb', line 14

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

Instance Method Details

#[](name) ⇒ Object

Parameters:

  • name (Object)

Returns:

  • (Object)


35
36
37
38
39
40
# File 'lib/datadog/tracing/contrib/registry.rb', line 35

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

#add(name, klass, auto_patch = false) ⇒ Object

Parameters:

  • name (Symbol) —

    instrumentation name, to be used when activating this integration

  • klass (Object) —

    instrumentation implementation

  • auto_patch (Boolean) (defaults to: false) —

    is the tracer allowed to automatically patch the host application with this instrumentation?

Returns:

  • (Object)


23
24
25
26
27
# File 'lib/datadog/tracing/contrib/registry.rb', line 23

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

#each(&block) ⇒ void

This method returns an undefined value.



29
30
31
32
33
# File 'lib/datadog/tracing/contrib/registry.rb', line 29

def each(&block)
  @mutex.synchronize do
    @data.each_value(&block)
  end
end

#to_h ⇒ Object

Returns:

  • (Object)


42
43
44
45
46
47
48
# File 'lib/datadog/tracing/contrib/registry.rb', line 42

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