Class: OpenTelemetry::Instrumentation::Registry
- Inherits:
-
Object
- Object
- OpenTelemetry::Instrumentation::Registry
- 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
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
-
#install(adapter_names, adapter_config_map = {}) ⇒ Object
Install the specified adapters with optionally specified configuration.
-
#install_all(adapter_config_map = {}) ⇒ Object
Install all instrumentation available and installable in this process.
-
#lookup(adapter_name) ⇒ Adapter
Lookup an adapter definition by name.
- #register(adapter) ⇒ Object private
Constructor Details
#initialize ⇒ Registry
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.
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.
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.
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 |