Class: NewRelic::TelemetrySdk::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/newrelic/telemetry_sdk/configurator.rb

Overview

The Configurator provides the mechanism through which the SDK is configured.

See Config for details on what properties can be configured.

Examples:

NewRelic::TelemetrySdk.configure do |config|
  config.api_insert_key = ENV["API_KEY"]
end

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)

Delegates any setter methods to the Config object if it responds to such. All other missing methods are propagated up the chain.



59
60
61
62
63
64
65
# File 'lib/newrelic/telemetry_sdk/configurator.rb', line 59

def method_missing method, *args, &block
  if method.to_s =~ /\=$/ && config.respond_to?(method)
    config.send method, *args, &block
  else
    super
  end
end

Class Method Details

.configObject



19
20
21
# File 'lib/newrelic/telemetry_sdk/configurator.rb', line 19

def self.config
  @config ||= Config.new
end

.resetObject

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.

Removes any configurations that were previously customized, effectively resetting the NewRelic::TelemetrySdk::Config state to defaults



27
28
29
# File 'lib/newrelic/telemetry_sdk/configurator.rb', line 27

def self.reset
  @config = nil
end

Instance Method Details

#configObject

Note:

Unlike configuring with # NewRelic::TelemetrySdk::Configurator#self#self.configure, setting config properties here may, or may not become immediately active. Use with care.

Allows direct access to the config state. The primary purpose of this method is to access config properties throughout the SDK.



38
39
40
# File 'lib/newrelic/telemetry_sdk/configurator.rb', line 38

def config
  Configurator.config
end

#configureObject

Set Telemetry SDK configuration with a block. See NewRelic::TelemetrySdk::Config for options.

Examples:

Setting the API Key

NewRelic::TelemetrySdk.configure do |config|
  config.api_insert_key = ENV["API_KEY"]
end


51
52
53
# File 'lib/newrelic/telemetry_sdk/configurator.rb', line 51

def configure
  Logger.logger = config.logger
end