Class: OpenTelemetry::SDK::Configurator
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Configurator
- Defined in:
- lib/opentelemetry/sdk/configurator.rb
Overview
The configurator provides defaults and facilitates configuring the SDK for use.
Instance Attribute Summary collapse
-
#http_extractors ⇒ Object
writeonly
Sets the attribute http_extractors.
-
#http_injectors ⇒ Object
writeonly
Sets the attribute http_injectors.
- #logger ⇒ Object
-
#text_map_extractors ⇒ Object
writeonly
Sets the attribute text_map_extractors.
-
#text_map_injectors ⇒ Object
writeonly
Sets the attribute text_map_injectors.
Instance Method Summary collapse
-
#add_span_processor(span_processor) ⇒ Object
Add a span processor to the export pipeline.
-
#configure ⇒ Object
private
The configure method is where we define the setup process.
-
#initialize ⇒ Configurator
constructor
A new instance of Configurator.
-
#resource=(new_resource) ⇒ Object
Accepts a resource object that is merged with the default telemetry sdk resource.
-
#service_name=(service_name) ⇒ Object
Accepts a string that is merged in as the service.name resource attribute.
-
#service_version=(service_version) ⇒ Object
Accepts a string that is merged in as the service.version resource attribute.
-
#use(instrumentation_name, config = nil) ⇒ Object
Install an instrumentation with specificied optional
config
. -
#use_all(instrumentation_config_map = {}) ⇒ Object
Install all registered instrumentation.
Constructor Details
#initialize ⇒ Configurator
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_map_extractors = nil @text_map_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
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
18 19 20 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 18 def http_injectors=(value) @http_injectors = value end |
#logger ⇒ Object
33 34 35 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 33 def logger @logger ||= OpenTelemetry.logger end |
#text_map_extractors=(value) ⇒ Object (writeonly)
Sets the attribute text_map_extractors
18 19 20 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 18 def text_map_extractors=(value) @text_map_extractors = value end |
#text_map_injectors=(value) ⇒ Object (writeonly)
Sets the attribute text_map_injectors
18 19 20 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 18 def text_map_injectors=(value) @text_map_injectors = value end |
Instance Method Details
#add_span_processor(span_processor) ⇒ Object
Add a span processor to the export pipeline
99 100 101 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 99 def add_span_processor(span_processor) @span_processors << span_processor end |
#configure ⇒ 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.
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
111 112 113 114 115 116 117 118 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 111 def configure OpenTelemetry.logger = logger OpenTelemetry.baggage = Baggage::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 include additional resource information. If a resource key collision occurs the passed in resource takes priority.
43 44 45 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 43 def resource=(new_resource) @resource = new_resource.merge(@resource) end |
#service_name=(service_name) ⇒ Object
Accepts a string that is merged in as the service.name resource attribute. The most recent assigned value will be used in the event of repeated calls to this setter.
51 52 53 54 55 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 51 def service_name=(service_name) @resource = OpenTelemetry::SDK::Resources::Resource.create( OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:name] => service_name ).merge(@resource) end |
#service_version=(service_version) ⇒ Object
Accepts a string that is merged in as the service.version resource attribute. The most recent assigned value will be used in the event of repeated calls to this setter.
61 62 63 64 65 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 61 def service_version=(service_version) @resource = OpenTelemetry::SDK::Resources::Resource.create( OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:version] => service_version ).merge(@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.
75 76 77 78 79 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 75 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.
89 90 91 92 |
# File 'lib/opentelemetry/sdk/configurator.rb', line 89 def use_all(instrumentation_config_map = {}) check_use_mode!(USE_MODE_ALL) @instrumentation_config_map = instrumentation_config_map end |