lib/elastic_apm/config.rb in elastic-apm-3.1.0 vs lib/elastic_apm/config.rb in elastic-apm-3.2.0
- old
+ new
@@ -1,13 +1,7 @@
# frozen_string_literal: true
-require 'logger'
-require 'yaml'
-require 'erb'
-
-require 'elastic_apm/util/prefixed_logger'
-
require 'elastic_apm/config/options'
require 'elastic_apm/config/duration'
require 'elastic_apm/config/bytes'
require 'elastic_apm/config/regexp_list'
@@ -26,10 +20,11 @@
option :active, type: :bool, default: true
option :api_buffer_size, type: :int, default: 256
option :api_request_size, type: :bytes, default: '750kb', converter: Bytes.new
option :api_request_time, type: :float, default: '10s', converter: Duration.new
+ option :breakdown_metrics, type: :bool, default: true
option :capture_body, type: :string, default: 'off'
option :capture_headers, type: :bool, default: true
option :capture_env, type: :bool, default: true
option :central_config, type: :bool, default: true
option :current_user_email_method, type: :string, default: 'email'
@@ -77,12 +72,10 @@
# rubocop:disable Metrics/MethodLength
def initialize(options = {})
@options = load_schema
- custom_logger = options.delete(:logger)
-
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
@@ -93,14 +86,14 @@
assign(load_config_file)
assign(env)
yield self if block_given?
- @logger = custom_logger || build_logger
+ self.logger ||= build_logger
- @__view_paths = []
- @__root_path = Dir.pwd
+ @__view_paths ||= []
+ @__root_path ||= Dir.pwd
end
# rubocop:enable Metrics/MethodLength
attr_accessor :__view_paths, :__root_path
attr_accessor :logger
@@ -170,9 +163,32 @@
end
def span_frames_min_duration_us
@span_frames_min_duration_us ||= span_frames_min_duration * 1_000_000
end
+
+ # rubocop:disable Metrics/MethodLength
+ 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
+ # rubocop:enable Metrics/MethodLength
def inspect
super.split.first + '>'
end