Class: OpenTelemetry::Instrumentation::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/instrumentation/registry.rb

Overview

The instrumentation Registry contains information about instrumentation adapters available and facilitates discovery, installation and configuration. This functionality is primarily useful for SDK implementors.

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



14
15
16
17
# File 'lib/opentelemetry/instrumentation/registry.rb', line 14

def initialize
  @lock = Mutex.new
  @adapters = []
end

Instance Method Details

#install(adapter_names, adapter_config_map = {}) ⇒ Object

Install the specified adapters with optionally specified configuration.

Parameters:

  • adapter_names (Array<String>)

    An array of adapter names to install

  • adapter_config_map (optional Hash<String, Hash>) (defaults to: {})

    A map of adapter_name to config. This argument is optional and config can be passed for as many or as few adapters as desired.



44
45
46
47
48
49
50
51
52
53
# File 'lib/opentelemetry/instrumentation/registry.rb', line 44

def install(adapter_names, adapter_config_map = {})
  @lock.synchronize do
    adapter_names.each do |adapter_name|
      adapter = find_adapter(adapter_name)
      OpenTelemetry.logger.warn "Could not install #{adapter_name} because it was not found" unless adapter

      install_adapter(adapter, adapter_config_map[adapter.name])
    end
  end
end

#install_all(adapter_config_map = {}) ⇒ Object

Install all instrumentation available and installable in this process.

Parameters:

  • adapter_config_map (optional Hash<String, Hash>) (defaults to: {})

    A map of adapter_name to config. This argument is optional and config can be passed for as many or as few adapters as desired.



60
61
62
63
64
65
66
# File 'lib/opentelemetry/instrumentation/registry.rb', line 60

def install_all(adapter_config_map = {})
  @lock.synchronize do
    @adapters.map(&:instance).each do |adapter|
      install_adapter(adapter, adapter_config_map[adapter.name])
    end
  end
end

#lookup(adapter_name) ⇒ Adapter

Lookup an adapter definition by name. Returns nil if +adapter_name+ is not found.

Parameters:

  • adapter_name (String)

    A stringified class name for an adapter

Returns:



31
32
33
34
35
# File 'lib/opentelemetry/instrumentation/registry.rb', line 31

def lookup(adapter_name)
  @lock.synchronize do
    find_adapter(adapter_name)
  end
end

#register(adapter) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
# File 'lib/opentelemetry/instrumentation/registry.rb', line 20

def register(adapter)
  @lock.synchronize do
    @adapters << adapter
  end
end