Class: OpenTelemetry::Instrumentation::Registry

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeRegistry

Returns a new instance of Registry.

[View source]

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.

Parameters:

  • instrumentation_names (Array<String>)

    An array of instrumentation names to install

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

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

[View source]

44
45
46
47
48
49
50
51
52
53
# 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)
      OpenTelemetry.logger.warn "Could not install #{instrumentation_name} because it was not found" unless instrumentation

      install_instrumentation(instrumentation, instrumentation_config_map[instrumentation.name])
    end
  end
end

#install_all(instrumentation_config_map = {}) ⇒ Object

Install all instrumentation available and installable in this process.

Parameters:

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

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

[View source]

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

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.

Parameters:

  • instrumentation_name (String)

    A stringified class name for an instrumentation

Returns:

[View source]

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.

[View source]

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

def register(instrumentation)
  @lock.synchronize do
    @instrumentation << instrumentation
  end
end