elastic-apm 2.9.1 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.jenkins_codecov.yml +5 -0
  3. data/.ci/.jenkins_exclude.yml +9 -19
  4. data/.ci/.jenkins_framework.yml +1 -4
  5. data/.ci/.jenkins_master_framework.yml +3 -0
  6. data/.ci/Jenkinsfile +43 -118
  7. data/.ci/downstreamTests.groovy +59 -30
  8. data/.ci/jobs/apm-agent-ruby-downstream.yml +31 -0
  9. data/.ci/jobs/apm-agent-ruby-mbp.yml +34 -0
  10. data/.ci/jobs/defaults.yml +1 -36
  11. data/.pre-commit-config.yaml +22 -0
  12. data/.rspec +0 -1
  13. data/.rubocop.yml +3 -3
  14. data/CHANGELOG.md +12 -0
  15. data/docs/api.asciidoc +2 -2
  16. data/docs/configuration.asciidoc +37 -1
  17. data/docs/metrics.asciidoc +77 -6
  18. data/lib/elastic_apm.rb +2 -2
  19. data/lib/elastic_apm/agent.rb +11 -2
  20. data/lib/elastic_apm/central_config.rb +141 -0
  21. data/lib/elastic_apm/central_config/cache_control.rb +34 -0
  22. data/lib/elastic_apm/config.rb +152 -338
  23. data/lib/elastic_apm/config/bytes.rb +25 -0
  24. data/lib/elastic_apm/config/duration.rb +6 -8
  25. data/lib/elastic_apm/config/options.rb +134 -0
  26. data/lib/elastic_apm/config/regexp_list.rb +13 -0
  27. data/lib/elastic_apm/metadata.rb +2 -1
  28. data/lib/elastic_apm/metrics.rb +2 -1
  29. data/lib/elastic_apm/metrics/vm.rb +57 -0
  30. data/lib/elastic_apm/normalizers/action_view.rb +1 -1
  31. data/lib/elastic_apm/railtie.rb +10 -5
  32. data/lib/elastic_apm/spies/mongo.rb +13 -2
  33. data/lib/elastic_apm/stacktrace_builder.rb +2 -2
  34. data/lib/elastic_apm/transport/connection.rb +2 -0
  35. data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +6 -1
  36. data/lib/elastic_apm/version.rb +1 -1
  37. metadata +11 -3
  38. data/lib/elastic_apm/config/size.rb +0 -28
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElasticAPM
4
+ class CentralConfig
5
+ # @api private
6
+ class CacheControl
7
+ def initialize(value)
8
+ @header = value
9
+ parse!(value)
10
+ end
11
+
12
+ attr_reader(
13
+ :must_revalidate,
14
+ :no_cache,
15
+ :no_store,
16
+ :no_transform,
17
+ :public,
18
+ :private,
19
+ :proxy_revalidate,
20
+ :max_age,
21
+ :s_maxage
22
+ )
23
+
24
+ private
25
+
26
+ def parse!(value)
27
+ value.split(',').each do |token|
28
+ k, v = token.split('=').map(&:strip)
29
+ instance_variable_set(:"@#{k.gsub('-', '_')}", v ? v.to_i : true)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -5,246 +5,109 @@ require 'yaml'
5
5
  require 'erb'
6
6
 
7
7
  require 'elastic_apm/util/prefixed_logger'
8
+
9
+ require 'elastic_apm/config/options'
8
10
  require 'elastic_apm/config/duration'
9
- require 'elastic_apm/config/size'
11
+ require 'elastic_apm/config/bytes'
12
+ require 'elastic_apm/config/regexp_list'
10
13
 
11
14
  module ElasticAPM
12
- class ConfigError < StandardError; end
13
-
14
15
  # rubocop:disable Metrics/ClassLength
15
16
  # @api private
16
17
  class Config
17
- DEFAULTS = {
18
- config_file: 'config/elastic_apm.yml',
19
-
20
- server_url: 'http://localhost:8200',
21
-
22
- active: true,
23
- api_buffer_size: 256,
24
- api_request_size: '750kb',
25
- api_request_time: '10s',
26
- capture_body: 'off',
27
- capture_headers: true,
28
- capture_env: true,
29
- current_user_email_method: :email,
30
- current_user_id_method: :id,
31
- current_user_username_method: :username,
32
- custom_key_filters: [],
33
- default_tags: {},
34
- disable_send: false,
35
- disable_start_message: false,
36
- disabled_spies: %w[json],
37
- environment: ENV['RAILS_ENV'] || ENV['RACK_ENV'],
38
- filter_exception_types: [],
39
- http_compression: true,
40
- ignore_url_patterns: [],
41
- instrument: true,
42
- instrumented_rake_tasks: [],
43
- log_level: Logger::INFO,
44
- log_path: nil,
45
- metrics_interval: '30s',
46
- pool_size: 1,
47
- source_lines_error_app_frames: 5,
48
- source_lines_error_library_frames: 0,
49
- source_lines_span_app_frames: 5,
50
- source_lines_span_library_frames: 0,
51
- span_frames_min_duration: '5ms',
52
- stack_trace_limit: 999_999,
53
- transaction_max_spans: 500,
54
- transaction_sample_rate: 1.0,
55
- verify_server_cert: true,
56
-
57
- view_paths: [],
58
- root_path: Dir.pwd
59
- }.freeze
60
-
61
- ENV_TO_KEY = {
62
- 'ELASTIC_APM_SERVER_URL' => 'server_url',
63
- 'ELASTIC_APM_SECRET_TOKEN' => 'secret_token',
64
-
65
- 'ELASTIC_APM_ACTIVE' => [:bool, 'active'],
66
- 'ELASTIC_APM_API_BUFFER_SIZE' => [:int, 'api_buffer_size'],
67
- 'ELASTIC_APM_API_REQUEST_SIZE' => [:int, 'api_request_size'],
68
- 'ELASTIC_APM_API_REQUEST_TIME' => 'api_request_time',
69
- 'ELASTIC_APM_CAPTURE_BODY' => 'capture_body',
70
- 'ELASTIC_APM_CAPTURE_HEADERS' => [:bool, 'capture_headers'],
71
- 'ELASTIC_APM_CAPTURE_ENV' => [:bool, 'capture_env'],
72
- 'ELASTIC_APM_CONFIG_FILE' => 'config_file',
73
- 'ELASTIC_APM_CUSTOM_KEY_FILTERS' => [:list, 'custom_key_filters'],
74
- 'ELASTIC_APM_DEFAULT_TAGS' => [:dict, 'default_tags'],
75
- 'ELASTIC_APM_DISABLED_SPIES' => [:list, 'disabled_spies'],
76
- 'ELASTIC_APM_DISABLE_SEND' => [:bool, 'disable_send'],
77
- 'ELASTIC_APM_DISABLE_START_MESSAGE' => [:bool, 'disable_start_message'],
78
- 'ELASTIC_APM_ENVIRONMENT' => 'environment',
79
- 'ELASTIC_APM_FRAMEWORK_NAME' => 'framework_name',
80
- 'ELASTIC_APM_FRAMEWORK_VERSION' => 'framework_version',
81
- 'ELASTIC_APM_HOSTNAME' => 'hostname',
82
- 'ELASTIC_APM_IGNORE_URL_PATTERNS' => [:list, 'ignore_url_patterns'],
83
- 'ELASTIC_APM_INSTRUMENT' => [:bool, 'instrument'],
84
- 'ELASTIC_APM_INSTRUMENTED_RAKE_TASKS' =>
85
- [:list, 'instrumented_rake_tasks'],
86
- 'ELASTIC_APM_LOG_LEVEL' => [:int, 'log_level'],
87
- 'ELASTIC_APM_LOG_PATH' => 'log_path',
88
- 'ELASTIC_APM_METRICS_INTERVAL' => 'metrics_interval',
89
- 'ELASTIC_APM_PROXY_ADDRESS' => 'proxy_address',
90
- 'ELASTIC_APM_PROXY_HEADERS' => [:dict, 'proxy_headers'],
91
- 'ELASTIC_APM_PROXY_PASSWORD' => 'proxy_password',
92
- 'ELASTIC_APM_PROXY_PORT' => [:int, 'proxy_port'],
93
- 'ELASTIC_APM_PROXY_USERNAME' => 'proxy_username',
94
- 'ELASTIC_APM_POOL_SIZE' => [:int, 'pool_size'],
95
- 'ELASTIC_APM_SERVER_CA_CERT' => 'server_ca_cert',
96
- 'ELASTIC_APM_SERVICE_NAME' => 'service_name',
97
- 'ELASTIC_APM_SERVICE_VERSION' => 'service_version',
98
- 'ELASTIC_APM_SOURCE_LINES_ERROR_APP_FRAMES' =>
99
- [:int, 'source_lines_error_app_frames'],
100
- 'ELASTIC_APM_SOURCE_LINES_ERROR_LIBRARY_FRAMES' =>
101
- [:int, 'source_lines_error_library_frames'],
102
- 'ELASTIC_APM_SOURCE_LINES_SPAN_APP_FRAMES' =>
103
- [:int, 'source_lines_span_app_frames'],
104
- 'ELASTIC_APM_SOURCE_LINES_SPAN_LIBRARY_FRAMES' =>
105
- [:int, 'source_lines_span_library_frames'],
106
- 'ELASTIC_APM_SPAN_FRAMES_MIN_DURATION' => 'span_frames_min_duration',
107
- 'ELASTIC_APM_STACK_TRACE_LIMIT' => [:int, 'stack_trace_limit'],
108
- 'ELASTIC_APM_TRANSACTION_MAX_SPANS' => [:int, 'transaction_max_spans'],
109
- 'ELASTIC_APM_TRANSACTION_SAMPLE_RATE' =>
110
- [:float, 'transaction_sample_rate'],
111
- 'ELASTIC_APM_VERIFY_SERVER_CERT' => [:bool, 'verify_server_cert']
112
- }.freeze
113
-
114
- DURATION_KEYS = %i[
115
- api_request_time
116
- span_frames_min_duration
117
- metrics_interval
18
+ extend Options
19
+
20
+ DEPRECATED_OPTIONS = %i[
21
+ compression_level=
22
+ compression_minimum_size=
23
+ debug_http=
24
+ debug_transactions=
25
+ flush_interval=
26
+ http_open_timeout=
27
+ http_read_timeout=
28
+ enabled_environments=
29
+ disable_environment_warning=
118
30
  ].freeze
119
- DURATION_DEFAULT_UNITS = { # default is 's'
120
- span_frames_min_duration: 'ms'
121
- }.freeze
122
31
 
123
- SIZE_KEYS = %i[api_request_size].freeze
124
- SIZE_DEFAULT_UNITS = { api_request_size: 'kb' }.freeze
32
+ # rubocop:disable Metrics/LineLength, Layout/ExtraSpacing
33
+ option :config_file, default: 'config/elastic_apm.yml'
34
+ option :server_url, default: 'http://localhost:8200'
35
+ option :secret_token
36
+
37
+ option :active, type: :bool, default: true
38
+ option :api_buffer_size, type: :int, default: 256
39
+ option :api_request_size, type: :bytes, default: '750kb', converter: Bytes.new
40
+ option :api_request_time, type: :float, default: '10s', converter: Duration.new
41
+ option :capture_body, type: :string, default: 'off'
42
+ option :capture_headers, type: :bool, default: true
43
+ option :capture_env, type: :bool, default: true
44
+ option :central_config, type: :bool, default: true
45
+ option :current_user_email_method, type: :string, default: 'email'
46
+ option :current_user_id_method, type: :string, default: 'id'
47
+ option :current_user_username_method, type: :string, default: 'username'
48
+ option :custom_key_filters, type: :list, default: [], converter: RegexpList.new
49
+ option :default_tags, type: :dict, default: {}
50
+ option :disable_send, type: :bool, default: false
51
+ option :disable_start_message, type: :bool, default: false
52
+ option :disabled_spies, type: :list, default: %w[json]
53
+ option :environment, type: :string, default: ENV['RAILS_ENV'] || ENV['RACK_ENV']
54
+ option :framework_name, type: :string
55
+ option :framework_version, type: :string
56
+ option :filter_exception_types, type: :list, default: []
57
+ option :global_labels, type: :dict
58
+ option :hostname, type: :string
59
+ option :http_compression, type: :bool, default: true
60
+ option :ignore_url_patterns, type: :list, default: [], converter: RegexpList.new
61
+ option :instrument, type: :bool, default: true
62
+ option :instrumented_rake_tasks, type: :list, default: []
63
+ option :log_level, type: :int, default: Logger::INFO
64
+ option :log_path, type: :string
65
+ option :metrics_interval, type: :int, default: '30s', converter: Duration.new
66
+ option :pool_size, type: :int, default: 1
67
+ option :proxy_address, type: :string
68
+ option :proxy_headers, type: :dict
69
+ option :proxy_password, type: :string
70
+ option :proxy_port, type: :int
71
+ option :proxy_username, type: :string
72
+ option :server_ca_cert, type: :string
73
+ option :service_name, type: :string
74
+ option :service_version, type: :string
75
+ option :source_lines_error_app_frames, type: :int, default: 5
76
+ option :source_lines_error_library_frames, type: :int, default: 0
77
+ option :source_lines_span_app_frames, type: :int, default: 5
78
+ option :source_lines_span_library_frames, type: :int, default: 0
79
+ option :span_frames_min_duration, type: :float, default: '5ms', converter: Duration.new(default_unit: 'ms')
80
+ option :stack_trace_limit, type: :int, default: 999_999
81
+ option :transaction_max_spans, type: :int, default: 500
82
+ option :transaction_sample_rate, type: :float, default: 1.0
83
+ option :verify_server_cert, type: :bool, default: true
84
+ # rubocop:enable Metrics/LineLength, Layout/ExtraSpacing
125
85
 
126
86
  def initialize(options = {})
127
- set_defaults
87
+ @options = load_schema
128
88
 
129
- set_from_args(options)
130
- set_from_config_file
131
- set_from_env
89
+ custom_logger = options.delete(:logger)
132
90
 
133
- normalize_durations
134
- normalize_sizes
91
+ assign(options)
92
+ assign(load_config_file)
93
+ assign(load_env)
135
94
 
136
95
  yield self if block_given?
137
96
 
138
- build_logger if logger.nil?
139
- end
140
-
141
- attr_accessor :config_file
142
-
143
- attr_accessor :server_url
144
- attr_accessor :secret_token
145
-
146
- attr_accessor :active
147
- attr_accessor :api_buffer_size
148
- attr_accessor :api_request_size
149
- attr_accessor :api_request_time
150
- attr_accessor :capture_env
151
- attr_accessor :capture_headers
152
- attr_accessor :current_user_email_method
153
- attr_accessor :current_user_id_method
154
- attr_accessor :current_user_method
155
- attr_accessor :current_user_username_method
156
- attr_accessor :default_tags
157
- attr_accessor :disable_send
158
- attr_accessor :disable_start_message
159
- attr_accessor :disabled_spies
160
- attr_accessor :environment
161
- attr_accessor :filter_exception_types
162
- attr_accessor :framework_name
163
- attr_accessor :framework_version
164
- attr_accessor :hostname
165
- attr_accessor :http_compression
166
- attr_accessor :instrument
167
- attr_accessor :instrumented_rake_tasks
168
- attr_accessor :log_level
169
- attr_accessor :log_path
170
- attr_accessor :logger
171
- attr_accessor :metrics_interval
172
- attr_accessor :pool_size
173
- attr_accessor :proxy_address
174
- attr_accessor :proxy_headers
175
- attr_accessor :proxy_password
176
- attr_accessor :proxy_port
177
- attr_accessor :proxy_username
178
- attr_accessor :server_ca_cert
179
- attr_accessor :service_name
180
- attr_accessor :service_version
181
- attr_accessor :source_lines_error_app_frames
182
- attr_accessor :source_lines_error_library_frames
183
- attr_accessor :source_lines_span_app_frames
184
- attr_accessor :source_lines_span_library_frames
185
- attr_accessor :stack_trace_limit
186
- attr_accessor :transaction_max_spans
187
- attr_accessor :transaction_sample_rate
188
- attr_accessor :verify_server_cert
189
-
190
- attr_reader :capture_body
191
- attr_reader :custom_key_filters
192
- attr_reader :ignore_url_patterns
193
- attr_reader :span_frames_min_duration
194
- attr_reader :span_frames_min_duration_us
195
-
196
- attr_writer :alert_logger
197
-
198
- attr_accessor :view_paths
199
- attr_accessor :root_path
200
-
201
- alias :active? :active
202
- alias :capture_body? :capture_body
203
- alias :capture_headers? :capture_headers
204
- alias :capture_env? :capture_env
205
- alias :disable_send? :disable_send
206
- alias :disable_start_message? :disable_start_message
207
- alias :http_compression? :http_compression
208
- alias :instrument? :instrument
209
- alias :verify_server_cert? :verify_server_cert
210
-
211
- def alert_logger
212
- @alert_logger ||= PrefixedLogger.new($stdout, prefix: Logging::PREFIX)
213
- end
214
-
215
- def app=(app)
216
- case app_type?(app)
217
- when :sinatra
218
- set_sinatra(app)
219
- when :rails
220
- set_rails(app)
221
- else
222
- self.service_name = 'ruby'
223
- end
224
- end
225
-
226
- def app_type?(app)
227
- if defined?(Rails::Application) && app.is_a?(Rails::Application)
228
- return :rails
229
- end
230
-
231
- if app.is_a?(Class) && app.superclass.to_s == 'Sinatra::Base'
232
- return :sinatra
233
- end
97
+ @logger = custom_logger || build_logger
234
98
 
235
- nil
99
+ @__view_paths = []
100
+ @__root_path = Dir.pwd
236
101
  end
237
102
 
238
- def use_ssl?
239
- server_url.start_with?('https')
240
- end
103
+ attr_accessor :__view_paths, :__root_path
104
+ attr_accessor :logger
241
105
 
242
- def custom_key_filters=(filters)
243
- @custom_key_filters = Array(filters).map(&Regexp.method(:new))
244
- end
106
+ attr_reader :options
245
107
 
246
- def ignore_url_patterns=(strings)
247
- @ignore_url_patterns = Array(strings).map(&Regexp.method(:new))
108
+ def assign(update)
109
+ return unless update
110
+ update.each { |key, value| send(:"#{key}=", value) }
248
111
  end
249
112
 
250
113
  # rubocop:disable Metrics/MethodLength
@@ -271,135 +134,111 @@ module ElasticAPM
271
134
  available_spies - disabled_spies
272
135
  end
273
136
 
274
- def span_frames_min_duration=(duration)
275
- @span_frames_min_duration = duration
276
- @span_frames_min_duration_us = duration * 1_000_000
277
- end
278
-
279
- def span_frames_min_duration?
280
- span_frames_min_duration != 0
281
- end
282
-
283
- DEPRECATED_OPTIONS = %i[
284
- compression_level=
285
- compression_minimum_size=
286
- debug_http=
287
- debug_transactions=
288
- flush_interval=
289
- http_open_timeout=
290
- http_read_timeout=
291
- enabled_environments=
292
- disable_environment_warning=
293
- ].freeze
294
-
295
- def respond_to_missing?(name)
296
- return true if DEPRECATED_OPTIONS.include? name
297
- return true if name.to_s.end_with?('=')
298
- false
299
- end
300
-
301
137
  def method_missing(name, *args)
302
- if DEPRECATED_OPTIONS.include?(name)
303
- alert_logger.warn "The option `#{name}' has been removed."
304
- return
305
- end
306
-
307
- if name.to_s.end_with?('=')
308
- raise ConfigError, "No such option `#{name.to_s.delete('=')}'"
309
- end
310
-
311
- super
138
+ return super unless DEPRECATED_OPTIONS.include?(name)
139
+ warn "The option `#{name}' has been removed."
312
140
  end
313
141
 
314
- def collect_metrics?
315
- metrics_interval > 0
142
+ def app=(app)
143
+ case app_type?(app)
144
+ when :sinatra
145
+ set_sinatra(app)
146
+ when :rails
147
+ set_rails(app)
148
+ else
149
+ self.service_name = 'ruby'
150
+ end
316
151
  end
317
152
 
318
153
  # rubocop:disable Metrics/MethodLength
319
154
  def capture_body=(value)
320
155
  if value =~ /(all|transactions|errors|off)/
321
- @capture_body = value
156
+ set(:capture_body, value)
322
157
  return
323
158
  end
324
159
 
325
160
  case value
326
161
  when true
327
- alert_logger.warn "Boolean value for option `capture_body' has " \
162
+ warn "Boolean value for option `capture_body' has " \
328
163
  "been deprecated. Setting to 'all'"
329
- @capture_body = 'all'
164
+ self.capture_body = 'all'
330
165
  when false
331
- alert_logger.warn "Boolean value for option `capture_body' has " \
166
+ warn "Boolean value for option `capture_body' has " \
332
167
  "been deprecated. Setting to 'off'"
333
- @capture_body = 'off'
168
+ self.capture_body = 'off'
334
169
  else
335
- default = DEFAULTS[:capture_body]
336
- alert_logger.warn "Unknown value `#{value}' for option "\
170
+ default = options[:capture_body].default
171
+ warn "Unknown value `#{value}' for option "\
337
172
  "`capture_body'. Defaulting to `#{default}'"
338
- @capture_body = default
173
+ self.capture_body = default
339
174
  end
340
175
  end
341
176
  # rubocop:enable Metrics/MethodLength
342
177
 
343
- private
178
+ def use_ssl?
179
+ server_url.start_with?('https')
180
+ end
344
181
 
345
- def assign(options)
346
- options.each do |key, value|
347
- send("#{key}=", value)
348
- end
182
+ def collect_metrics?
183
+ metrics_interval > 0
349
184
  end
350
185
 
351
- def set_defaults
352
- assign(DEFAULTS)
186
+ def span_frames_min_duration?
187
+ span_frames_min_duration != 0
353
188
  end
354
189
 
355
- # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
356
- # rubocop:disable Metrics/AbcSize
357
- def set_from_env
358
- ENV_TO_KEY.each do |env_key, key|
359
- next unless (value = ENV[env_key])
360
-
361
- type, key = key if key.is_a? Array
362
-
363
- value =
364
- case type
365
- when :int then value.to_i
366
- when :float then value.to_f
367
- when :bool then !%w[0 false].include?(value.strip.downcase)
368
- when :list then value.split(/[ ,]/)
369
- when :dict then Hash[value.split(/[&,]/).map { |kv| kv.split('=') }]
370
- else value
371
- end
372
-
373
- send("#{key}=", value)
374
- end
190
+ def span_frames_min_duration=(value)
191
+ super
192
+ @span_frames_min_duration_us = nil
375
193
  end
376
- # rubocop:enable Metrics/AbcSize
377
- # rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
378
194
 
379
- def set_from_args(options)
380
- assign(options)
381
- rescue ConfigError => e
382
- alert_logger.warn format(
383
- 'Failed to configure from arguments: %s',
384
- e.message
385
- )
195
+ def span_frames_min_duration_us
196
+ @span_frames_min_duration_us ||= span_frames_min_duration * 1_000_000
197
+ end
198
+
199
+ def inspect
200
+ super.split.first + '>'
386
201
  end
387
202
 
388
- def set_from_config_file
203
+ private
204
+
205
+ def load_config_file
389
206
  return unless File.exist?(config_file)
390
- assign(YAML.safe_load(ERB.new(File.read(config_file)).result) || {})
391
- rescue ConfigError => e
392
- alert_logger.warn format(
393
- 'Failed to configure from config file: %s',
394
- e.message
395
- )
207
+
208
+ config = YAML.safe_load(ERB.new(File.read(config_file)).result)
209
+ assign(config)
210
+ end
211
+
212
+ def load_env
213
+ @options.values.each_with_object({}) do |option, opts|
214
+ next unless (value = ENV[option.env_key])
215
+ opts[option.key] = value
216
+ end
217
+ end
218
+
219
+ def build_logger
220
+ Logger.new(log_path == '-' ? STDOUT : log_path).tap do |logger|
221
+ logger.level = log_level
222
+ end
223
+ end
224
+
225
+ def app_type?(app)
226
+ if defined?(Rails::Application) && app.is_a?(Rails::Application)
227
+ return :rails
228
+ end
229
+
230
+ if app.is_a?(Class) && app.superclass.to_s == 'Sinatra::Base'
231
+ return :sinatra
232
+ end
233
+
234
+ nil
396
235
  end
397
236
 
398
237
  def set_sinatra(app)
399
238
  self.service_name = format_name(service_name || app.to_s)
400
239
  self.framework_name = framework_name || 'Sinatra'
401
240
  self.framework_version = framework_version || Sinatra::VERSION
402
- self.root_path = Dir.pwd
241
+ self.__root_path = Dir.pwd
403
242
  end
404
243
 
405
244
  def set_rails(app) # rubocop:disable Metrics/AbcSize
@@ -408,8 +247,8 @@ module ElasticAPM
408
247
  self.framework_version ||= Rails::VERSION::STRING
409
248
  self.logger ||= Rails.logger
410
249
 
411
- self.root_path = Rails.root.to_s
412
- self.view_paths = app.config.paths['app/views'].existent
250
+ self.__root_path = Rails.root.to_s
251
+ self.__view_paths = app.config.paths['app/views'].existent
413
252
  end
414
253
 
415
254
  def rails_app_name(app)
@@ -420,34 +259,9 @@ module ElasticAPM
420
259
  end
421
260
  end
422
261
 
423
- def build_logger
424
- logger = Logger.new(log_path == '-' ? STDOUT : log_path)
425
- logger.level = log_level
426
-
427
- self.logger = logger
428
- end
429
-
430
262
  def format_name(str)
431
263
  str && str.gsub('::', '_')
432
264
  end
433
-
434
- def normalize_durations
435
- DURATION_KEYS.each do |key|
436
- value = send(key).to_s
437
- default_unit = DURATION_DEFAULT_UNITS.fetch(key, 's')
438
- duration = Duration.parse(value, default_unit: default_unit)
439
- send("#{key}=", duration.seconds)
440
- end
441
- end
442
-
443
- def normalize_sizes
444
- SIZE_KEYS.each do |key|
445
- value = send(key).to_s
446
- default_unit = SIZE_DEFAULT_UNITS.fetch(key, 'b')
447
- size = Size.parse(value, default_unit: default_unit)
448
- send("#{key}=", size.bytes)
449
- end
450
- end
451
265
  end
452
266
  # rubocop:enable Metrics/ClassLength
453
267
  end