Class: Atatus::Config Private

Inherits:
Object
  • Object
show all
Extended by:
Options
Defined in:
lib/atatus/config.rb,
lib/atatus/config/bytes.rb,
lib/atatus/config/options.rb,
lib/atatus/config/duration.rb,
lib/atatus/config/regexp_list.rb,
lib/atatus/config/wildcard_pattern_list.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: Options Classes: Bytes, Duration, RegexpList, WildcardPatternList

Constant Summary collapse

DEPRECATED_OPTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Options

extended

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Config

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.

rubocop:enable Metrics/LineLength, Layout/ExtraSpacing

Yields:

  • (_self)

Yield Parameters:



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/atatus/config.rb', line 105

def initialize(options = {})
  @options = load_schema

  assign(options)

  # Pick out config_file specifically as we need it now to load it,
  # but still need the other env vars to have precedence
  env = load_env
  if (env_config_file = env.delete(:config_file))
    self.config_file = env_config_file
  end

  assign(load_config_file)
  assign(env)

  yield self if block_given?

  self.logger ||= build_logger

  @__view_paths ||= []
  @__root_path ||= Dir.pwd
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ 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.



166
167
168
169
# File 'lib/atatus/config.rb', line 166

def method_missing(name, *args)
  return super unless DEPRECATED_OPTIONS.include?(name)
  warn "The option `#{name}' has been removed."
end

Instance Attribute Details

#__root_pathObject

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.



128
129
130
# File 'lib/atatus/config.rb', line 128

def __root_path
  @__root_path
end

#__view_pathsObject

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.



128
129
130
# File 'lib/atatus/config.rb', line 128

def __view_paths
  @__view_paths
end

#loggerObject

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.



129
130
131
# File 'lib/atatus/config.rb', line 129

def logger
  @logger
end

#optionsObject (readonly)

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.



131
132
133
# File 'lib/atatus/config.rb', line 131

def options
  @options
end

Instance Method Details

#activeObject Also known as: active?

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.



267
268
269
# File 'lib/atatus/config.rb', line 267

def active
  enabled
end

#active=(value) ⇒ 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.



283
284
285
286
287
# File 'lib/atatus/config.rb', line 283

def active=(value)
  warn '[DEPRECATED] The option active has been renamed to enabled ' \
    'to align with other agents and with the remote config.'
  self.enabled = value
end

#app=(app) ⇒ 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.



180
181
182
183
184
185
186
187
188
189
# File 'lib/atatus/config.rb', line 180

def app=(app)
  case app_type?(app)
  when :sinatra
    set_sinatra(app)
  when :rails
    set_rails(app)
  else
    self.service_name = 'ruby'
  end
end

#assign(update) ⇒ 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.



133
134
135
136
# File 'lib/atatus/config.rb', line 133

def assign(update)
  return unless update
  update.each { |key, value| send(:"#{key}=", value) }
end

#available_instrumentationsObject

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.



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/atatus/config.rb', line 138

def available_instrumentations
  %w[
    action_dispatch
    delayed_job
    dynamo_db
    elasticsearch
    faraday
    http
    json
    mongo
    net_http
    rake
    redis
    resque
    sequel
    shoryuken
    sidekiq
    sinatra
    sneakers
    sucker_punch
    tilt
  ]
end

#collect_metrics?Boolean

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:

  • (Boolean)


195
196
197
# File 'lib/atatus/config.rb', line 195

def collect_metrics?
  metrics_interval > 0
end

#custom_key_filters=(value) ⇒ 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.



254
255
256
257
258
259
260
261
# File 'lib/atatus/config.rb', line 254

def custom_key_filters=(value)
  unless value == self.class.schema[:custom_key_filters][:default]
    warn '[DEPRECATED] The option custom_key_filters is being removed. ' \
      'See sanitize_field_names for an alternative.'
  end

  set(:custom_key_filters, value)
end

#default_tags=(value) ⇒ 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.

Deprecations



239
240
241
242
243
# File 'lib/atatus/config.rb', line 239

def default_tags=(value)
  warn '[DEPRECATED] The option default_tags has been renamed to ' \
    'default_labels.'
  self.default_labels = value
end

#disabled_instrumentationsObject

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.



263
264
265
# File 'lib/atatus/config.rb', line 263

def disabled_instrumentations
  disable_instrumentations
end

#disabled_instrumentations=(value) ⇒ 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.



272
273
274
275
276
# File 'lib/atatus/config.rb', line 272

def disabled_instrumentations=(value)
  warn '[DEPRECATED] The option disabled_instrumentations has been ' \
    'renamed to disable_instrumentations to align with other agents.'
  self.disable_instrumentations = value
end

#enabled_instrumentationsObject

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.



162
163
164
# File 'lib/atatus/config.rb', line 162

def enabled_instrumentations
  available_instrumentations - disable_instrumentations
end

#ignore_url_patterns=(value) ⇒ 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.



245
246
247
248
249
250
251
252
# File 'lib/atatus/config.rb', line 245

def ignore_url_patterns=(value)
  unless value == self.class.schema[:ignore_url_patterns][:default]
    warn '[DEPRECATED] The option ignore_url_patterns is being removed. ' \
      'Consider using transaction_ignore_urls instead.'
  end

  set(:ignore_url_patterns, value)
end

#inspectObject

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.



233
234
235
# File 'lib/atatus/config.rb', line 233

def inspect
  super.split.first + '>'
end

#replace_options(new_options) ⇒ 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.



171
172
173
174
175
176
177
178
# File 'lib/atatus/config.rb', line 171

def replace_options(new_options)
  return if new_options.nil? || new_options.empty?
  options_copy = @options.dup
  new_options.each do |key, value|
    options_copy.fetch(key.to_sym).set(value)
  end
  @options = options_copy
end

#span_frames_min_duration=(value) ⇒ 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.



203
204
205
206
# File 'lib/atatus/config.rb', line 203

def span_frames_min_duration=(value)
  super
  @span_frames_min_duration_us = nil
end

#span_frames_min_duration?Boolean

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:

  • (Boolean)


199
200
201
# File 'lib/atatus/config.rb', line 199

def span_frames_min_duration?
  span_frames_min_duration != 0
end

#span_frames_min_duration_usObject

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.



208
209
210
# File 'lib/atatus/config.rb', line 208

def span_frames_min_duration_us
  @span_frames_min_duration_us ||= span_frames_min_duration * 1_000_000
end

#ssl_contextObject

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.



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/atatus/config.rb', line 212

def ssl_context
  return unless use_ssl?

  @ssl_context ||=
    OpenSSL::SSL::SSLContext.new.tap do |context|
      if server_ca_cert
        context.ca_file = server_ca_cert
      else
        context.cert_store =
          OpenSSL::X509::Store.new.tap(&:set_default_paths)
      end

      context.verify_mode =
        if verify_server_cert
          OpenSSL::SSL::VERIFY_PEER
        else
          OpenSSL::SSL::VERIFY_NONE
        end
    end
end

#use_experimental_sql_parser=(value) ⇒ 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.



278
279
280
281
# File 'lib/atatus/config.rb', line 278

def use_experimental_sql_parser=(value)
  warn '[DEPRECATED] The new SQL parser is now the default. To use the old one, '
    'use use_legacy_sql_parser and please report why you wish to do so.'
end

#use_ssl?Boolean

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:

  • (Boolean)


191
192
193
# File 'lib/atatus/config.rb', line 191

def use_ssl?
  server_url.start_with?('https')
end