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 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(instrumentation_names, instrumentation_config_map = {}) ⇒ Object
Install the specified instrumentation with optionally specified configuration.
-
#install_all(instrumentation_config_map = {}) ⇒ Object
Install all instrumentation available and installable in this process.
-
#lookup(instrumentation_name) ⇒ Instrumentation
Lookup an instrumentation definition by name.
- #register(instrumentation) ⇒ 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 @instrumentation = [] end |
Instance Method Details
#install(instrumentation_names, instrumentation_config_map = {}) ⇒ Object
Install the specified instrumentation with optionally specified configuration.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/opentelemetry/instrumentation/registry.rb', line 44 def install(instrumentation_names, instrumentation_config_map = {}) @lock.synchronize do instrumentation_names.each do |instrumentation_name| instrumentation = find_instrumentation(instrumentation_name) if instrumentation.nil? OpenTelemetry.logger.warn "Could not install #{instrumentation_name} because it was not found" else install_instrumentation(instrumentation, instrumentation_config_map[instrumentation.name]) end end end end |
#install_all(instrumentation_config_map = {}) ⇒ Object
Install all instrumentation available and installable in this process.
62 63 64 65 66 67 68 |
# File 'lib/opentelemetry/instrumentation/registry.rb', line 62 def install_all(instrumentation_config_map = {}) @lock.synchronize do @instrumentation.map(&:instance).each do |instrumentation| install_instrumentation(instrumentation, instrumentation_config_map[instrumentation.name]) end end end |
#lookup(instrumentation_name) ⇒ Instrumentation
Lookup an instrumentation definition by name. Returns nil if +instrumentation_name+ is not found.
31 32 33 34 35 |
# File 'lib/opentelemetry/instrumentation/registry.rb', line 31 def lookup(instrumentation_name) @lock.synchronize do find_instrumentation(instrumentation_name) end end |
#register(instrumentation) ⇒ 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(instrumentation) @lock.synchronize do @instrumentation << instrumentation end end |