Class: NewRelic::TelemetrySdk::Config

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

Overview

This class allows setting configuration options for the Telemetry SDK via NewRelic::TelemetrySdk.configure.

Examples:

Setting the API Key

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

Constant Summary collapse

DEFAULT_TRACE_API_HOST =

Default host for the Trace Client

"https://trace-api.newrelic.com"
DEFAULT_HARVEST_INTERVAL =

Default harvest interval in seconds

5
DEFAULT_BACKOFF_FACTOR =

Default backoff strategy factorial

5
DEFAULT_BACKOFF_MAX =

Default maximum backoff wait time in seconds

80
DEFAULT_MAX_RETRIES =

Default number of retries to send same data

8

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

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.

Returns a new instance of Config.



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/newrelic/telemetry_sdk/config.rb', line 84

def initialize
  @api_insert_key = ENV[API_INSERT_KEY]
  @logger = Logger.logger
  @audit_logging_enabled = false

  @harvest_interval = DEFAULT_HARVEST_INTERVAL
  @backoff_factor = DEFAULT_BACKOFF_FACTOR
  @backoff_max = DEFAULT_BACKOFF_MAX
  @max_retries = DEFAULT_MAX_RETRIES
  @trace_api_host = DEFAULT_TRACE_API_HOST
end

Instance Attribute Details

#api_insert_keyObject

A New Relic Insert API key. Necessary for sending data to New Relic via the Telemetry SDK. Defaults to API_INSERT_KEY environment variable.



40
41
42
# File 'lib/newrelic/telemetry_sdk/config.rb', line 40

def api_insert_key
  @api_insert_key
end

#audit_logging_enabledObject

If audit logging is enabled, the contents of every payload sent to New Relic will be recorded in logs. This is a very verbose log level for debugging purposes.



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

def audit_logging_enabled
  @audit_logging_enabled
end

#backoff_factorObject

The amount of time (in seconds) to wait after sending data to New Relic fails before attempting to send again. Defaults to DEFAULT_HARVEST_INTERVAL seconds.



63
64
65
# File 'lib/newrelic/telemetry_sdk/config.rb', line 63

def backoff_factor
  @backoff_factor
end

#backoff_maxObject

If data cannot be sent to New Relic intermittently, the SDK will retry the request at increasing intervals, but will stop increasing the retry intervals when they have reached backoff_max seconds. Defaults to DEFAULT_BACKOFF_MAX seconds.



71
72
73
# File 'lib/newrelic/telemetry_sdk/config.rb', line 71

def backoff_max
  @backoff_max
end

#harvest_intervalObject

The frequency of automatic harvest (in seconds) if sending data with a harvester. Defaults to DEFAULT_HARVEST_INTERVAL seconds.



57
58
59
# File 'lib/newrelic/telemetry_sdk/config.rb', line 57

def harvest_interval
  @harvest_interval
end

#loggerObject

A Logger object customized with your preferred log output destination (if any) and log level.



45
46
47
# File 'lib/newrelic/telemetry_sdk/config.rb', line 45

def logger
  @logger
end

#max_retriesObject

The maximum number of times to retry sending data to New Relic. Defaults to DEFAULT_MAX_RETRIES.



76
77
78
# File 'lib/newrelic/telemetry_sdk/config.rb', line 76

def max_retries
  @max_retries
end

#trace_api_hostObject

An alternative New Relic host URL where spans can be sent. Defaults to DEFAULT_TRACE_API_HOST



81
82
83
# File 'lib/newrelic/telemetry_sdk/config.rb', line 81

def trace_api_host
  @trace_api_host
end