Class: OpenTelemetry::SDK::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/sdk/configurator.rb

Overview

The configurator provides defaults and facilitates configuring the SDK for use.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfigurator

Returns a new instance of Configurator.



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/opentelemetry/sdk/configurator.rb', line 21

def initialize
  @instrumentation_names = []
  @instrumentation_config_map = {}
  @http_extractors = nil
  @http_injectors = nil
  @text_extractors = nil
  @text_injectors = nil
  @span_processors = []
  @use_mode = USE_MODE_UNSPECIFIED
  @resource = Resources::Resource.telemetry_sdk
end

Instance Attribute Details

#http_extractors=(value) ⇒ Object (writeonly)

Sets the attribute http_extractors

Parameters:

  • value

    the value to set the attribute http_extractors to.



18
19
20
# File 'lib/opentelemetry/sdk/configurator.rb', line 18

def http_extractors=(value)
  @http_extractors = value
end

#http_injectors=(value) ⇒ Object (writeonly)

Sets the attribute http_injectors

Parameters:

  • value

    the value to set the attribute http_injectors to.



18
19
20
# File 'lib/opentelemetry/sdk/configurator.rb', line 18

def http_injectors=(value)
  @http_injectors = value
end

#loggerObject



33
34
35
# File 'lib/opentelemetry/sdk/configurator.rb', line 33

def logger
  @logger ||= Logger.new(STDOUT)
end

#text_extractors=(value) ⇒ Object (writeonly)

Sets the attribute text_extractors

Parameters:

  • value

    the value to set the attribute text_extractors to.



18
19
20
# File 'lib/opentelemetry/sdk/configurator.rb', line 18

def text_extractors=(value)
  @text_extractors = value
end

#text_injectors=(value) ⇒ Object (writeonly)

Sets the attribute text_injectors

Parameters:

  • value

    the value to set the attribute text_injectors to.



18
19
20
# File 'lib/opentelemetry/sdk/configurator.rb', line 18

def text_injectors=(value)
  @text_injectors = value
end

Instance Method Details

#add_span_processor(span_processor) ⇒ Object

Add a span processor to the export pipeline

Parameters:

  • span_processor (#on_start, #on_finish, #shutdown)

    A span_processor that satisfies the duck type #on_start, #on_finish, #shutdown. See SimpleSpanProcessor for an example.



78
79
80
# File 'lib/opentelemetry/sdk/configurator.rb', line 78

def add_span_processor(span_processor)
  @span_processors << span_processor
end

#configureObject

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.

The configure method is where we define the setup process. This allows us to make certain guarantees about which systems and globals are setup at each stage. The setup process is:

  • setup logging
  • setup propagation
  • setup tracer_provider and meter_provider
  • install instrumentation


90
91
92
93
94
95
96
97
# File 'lib/opentelemetry/sdk/configurator.rb', line 90

def configure
  OpenTelemetry.logger = logger
  OpenTelemetry.correlations = CorrelationContext::Manager.new
  configure_propagation
  configure_span_processors
  OpenTelemetry.tracer_provider = tracer_provider
  install_instrumentation
end

#resource=(new_resource) ⇒ Object

Accepts a resource object that is merged with the default telemetry sdk resource. The use of this method is optional, and is provided as means to add additional resource information.

Parameters:

  • new_resource (Resource)

    The resource to be merged



42
43
44
# File 'lib/opentelemetry/sdk/configurator.rb', line 42

def resource=(new_resource)
  @resource = @resource.merge(new_resource)
end

#use(instrumentation_name, config = nil) ⇒ Object

Install an instrumentation with specificied optional +config+. Use can be called multiple times to install multiple instrumentation. Only +use+ or +use_all+, but not both when installing instrumentation. A call to +use_all+ after +use+ will result in an exception.

Parameters:

  • instrumentation_name (String)

    The name of the instrumentation

  • config (optional Hash) (defaults to: nil)

    The config for this instrumentation



54
55
56
57
58
# File 'lib/opentelemetry/sdk/configurator.rb', line 54

def use(instrumentation_name, config = nil)
  check_use_mode!(USE_MODE_ONE)
  @instrumentation_names << instrumentation_name
  @instrumentation_config_map[instrumentation_name] = config if config
end

#use_all(instrumentation_config_map = {}) ⇒ Object

Install all registered instrumentation. Configuration for specific instrumentation can be provided with the optional +instrumentation_config_map+ parameter. Only +use+ or +use_all+, but not both when installing instrumentation. A call to +use+ after +use_all+ will result in an exception.

Parameters:

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

    A map with string keys representing the instrumentation name and values specifying the instrumentation config



68
69
70
71
# File 'lib/opentelemetry/sdk/configurator.rb', line 68

def use_all(instrumentation_config_map = {})
  check_use_mode!(USE_MODE_ALL)
  @instrumentation_config_map = instrumentation_config_map
end