Class: ElasticAPM::Config Private

Inherits:
Object
  • Object
show all
Extended by:
Options
Defined in:
lib/elastic_apm/config.rb,
lib/elastic_apm/config/bytes.rb,
lib/elastic_apm/config/options.rb,
lib/elastic_apm/config/duration.rb,
lib/elastic_apm/config/regexp_list.rb,
lib/elastic_apm/config/round_float.rb,
lib/elastic_apm/config/log_level_map.rb,
lib/elastic_apm/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, LogLevelMap, RegexpList, RoundFloat, WildcardPatternList

Constant Summary collapse

SANITIZE_FIELD_NAMES_DEFAULT =

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.

%w[password passwd pwd secret *key *token* *session* *credit* *card* authorization set-cookie].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 Layout/LineLength, Layout/ExtraSpacing

Yields:

  • (_self)

Yield Parameters:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/elastic_apm/config.rb', line 101

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

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.



124
125
126
# File 'lib/elastic_apm/config.rb', line 124

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.



124
125
126
# File 'lib/elastic_apm/config.rb', line 124

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.



124
125
126
# File 'lib/elastic_apm/config.rb', line 124

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.



126
127
128
# File 'lib/elastic_apm/config.rb', line 126

def options
  @options
end

Instance Method Details

#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.



173
174
175
176
177
178
179
180
181
182
# File 'lib/elastic_apm/config.rb', line 173

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.



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

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.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/elastic_apm/config.rb', line 133

def available_instrumentations
  %w[
    action_dispatch
    delayed_job
    dynamo_db
    elasticsearch
    faraday
    http
    json
    mongo
    net_http
    rake
    redis
    resque
    s3
    sequel
    shoryuken
    sidekiq
    sinatra
    sneakers
    sns
    sqs
    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)


188
189
190
# File 'lib/elastic_apm/config.rb', line 188

def collect_metrics?
  metrics_interval > 0
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.



160
161
162
# File 'lib/elastic_apm/config.rb', line 160

def enabled_instrumentations
  available_instrumentations - disable_instrumentations
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.



226
227
228
# File 'lib/elastic_apm/config.rb', line 226

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.



164
165
166
167
168
169
170
171
# File 'lib/elastic_apm/config.rb', line 164

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.



196
197
198
199
# File 'lib/elastic_apm/config.rb', line 196

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)


192
193
194
# File 'lib/elastic_apm/config.rb', line 192

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.



201
202
203
# File 'lib/elastic_apm/config.rb', line 201

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.



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/elastic_apm/config.rb', line 205

def ssl_context
  return unless use_ssl?

  @ssl_context ||=
    OpenSSL::SSL::SSLContext.new.tap do |context|
      if server_ca_cert_file
        context.ca_file = server_ca_cert_file
      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_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)


184
185
186
# File 'lib/elastic_apm/config.rb', line 184

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