elastic-apm 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc66ce3466effa6740c0b8c9dbb0d74358b54d9039ceebe2938674170e68662b
4
- data.tar.gz: d3288b6cf41bbe33fb6594789371d36fcb66ccc2b9ec9d8d2f6aed08f4d212f7
3
+ metadata.gz: 9bd0b20acebcfa91bc6e5d4e580c6a1a5f8da35b06152a4fe949c76380667e58
4
+ data.tar.gz: 85935357d8a1831233cb8ab837564b38ff800e29a0cf1891fd4ba6263bb1a0d2
5
5
  SHA512:
6
- metadata.gz: 6fcdb201cf7b1824776fffff92e8fc538613928b4ae977f694f67239c15a9e10f14a1ceb4669248eb658c4b2fd439398d0badd231292367e8371655cd2bae738
7
- data.tar.gz: 72fdb5641db042a4c7ccd6fcdfc97d43949d1f8ed0b561029e6beffa640262d04c2a639f5f75944b944c1283dae8b2c929f0a3aae14e7e2547af3e942e4307a8
6
+ metadata.gz: 6eabaee4c14440607bdc5b5a0e53fd8b3844e0756a16cf6ef0da4b2a5431e7c1b441d0ef6329baf7d89f165f44031aa6a8396541930576acf54b254a787994cc
7
+ data.tar.gz: e601985643738456350d49ba9c261ccc17a0259651830230cf353d20c241403846f73c3ce371ab5b6f1a97b1223ac797ddfc1b764333e51055ff53104becd212
@@ -15,6 +15,7 @@
15
15
  repo: apm-agent-ruby
16
16
  repo-owner: elastic
17
17
  credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
18
+ head-filter-regex: '^(master|PR-.*|[3-4]\.x)$'
18
19
  ssh-checkout:
19
20
  credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
20
21
  build-strategies:
data/CHANGELOG.asciidoc CHANGED
@@ -35,6 +35,18 @@ endif::[]
35
35
  [[release-notes-4.x]]
36
36
  === Ruby Agent version 4.x
37
37
 
38
+ [[release-notes-4.4.0]]
39
+ ==== 4.4.0
40
+
41
+ [float]
42
+ ===== Added
43
+ - Optional span to be ended instead of current span {pull}1039[#1039]
44
+ - Config option `log_ecs_formatting` {pull}1053[#1053]
45
+
46
+ [float]
47
+ ===== Fixed
48
+ - Fixed detecting Linux on Alpine for CPU/MEM metrics {pull}1057[#1057]
49
+
38
50
  [[release-notes-4.3.0]]
39
51
  ==== 4.3.0
40
52
 
data/Gemfile CHANGED
@@ -37,6 +37,7 @@ gem 'aws-sdk-s3', require: nil
37
37
  gem 'aws-sdk-sqs', require: nil
38
38
  gem 'aws-sdk-sns', require: nil
39
39
  gem 'azure-storage-table', require: nil if RUBY_VERSION < '3.0'
40
+ gem 'ecs-logging', require: 'ecs_logging/logger'
40
41
  gem 'elasticsearch', require: nil
41
42
  gem 'fakeredis', require: nil
42
43
  gem 'faraday', require: nil
@@ -502,7 +502,31 @@ Use this option to ignore certain URL patterns such as healthchecks or admin sec
502
502
  | `ELASTIC_APM_INSTRUMENTED_RAKE_TASKS` | `instrumented_rake_tasks` | `[]` | `['my_task']`
503
503
  |============
504
504
 
505
- Elastic APM can instrument your Rake tasks. Theis is an opt-in field, as they are used are for a multitude of things.
505
+ Elastic APM can instrument your Rake tasks. Theis is an opt-in field, as they are used are for a multitude of things.
506
+
507
+ [float]
508
+ [[config-log-ecs-formatting]]
509
+ ==== `log_ecs_formatting`
510
+
511
+ [options="header"]
512
+ |============
513
+ | Environment | `Config` key | Default
514
+ | `ELASTIC_APM_LOG_ECS_FORMATTING` | `log_ecs_formatting` | `off`
515
+ |============
516
+
517
+ This is an experimental option that configures the agent to use the logger from the `ecs-logging` gem. The two
518
+ valid options are `off` and `override`.
519
+
520
+ Setting this option to `override` will set the agent logger to a `EcsLogging::Logger` instance and all logged output
521
+ will be in ECS-compatible json.
522
+
523
+ The `ecs-logging` gem must be installed before the agent is started. If `log_ecs_formatting` is set to `override`,
524
+ the agent will attempt to require the gem and if it cannot be loaded, it will fall back to using the standard Ruby
525
+ `::Logger` and log the load error.
526
+
527
+ Note that if you're using Rails, the agent will ignore this option and use the Rails logger. If you want to use a
528
+ `EcsLogging::Logger` when using Rails, set the agent's logger config option explicitly to a `EcsLogging::Logger`
529
+ instance.
506
530
 
507
531
  [float]
508
532
  [[config-log-level]]
@@ -211,8 +211,8 @@ module ElasticAPM
211
211
  end
212
212
  # rubocop:enable Metrics/ParameterLists
213
213
 
214
- def end_span
215
- instrumenter.end_span
214
+ def end_span(span = nil)
215
+ instrumenter.end_span(span)
216
216
  end
217
217
 
218
218
  def set_label(key, value)
@@ -70,6 +70,7 @@ module ElasticAPM
70
70
  option :ignore_url_patterns, type: :list, default: [], converter: RegexpList.new
71
71
  option :instrument, type: :bool, default: true
72
72
  option :instrumented_rake_tasks, type: :list, default: []
73
+ option :log_ecs_formatting, type: :string, default: 'off'
73
74
  option :log_level, type: :int, default: Logger::INFO, converter: LogLevelMap.new
74
75
  option :log_path, type: :string
75
76
  option :metrics_interval, type: :int, default: '30s', converter: Duration.new
@@ -246,11 +247,29 @@ module ElasticAPM
246
247
  end
247
248
 
248
249
  def build_logger
250
+ if self.log_ecs_formatting == 'override'
251
+ begin
252
+ return build_ecs_logger
253
+ rescue LoadError
254
+ logger.info "Attempted to use EcsLogging::Logger but the gem couldn't be " \
255
+ "loaded so a ::Logger was created instead. Check if you have the `ecs-logging` " \
256
+ "gem installed and attempt to start the agent again."
257
+ end
258
+ end
259
+
249
260
  Logger.new(log_path == '-' ? $stdout : log_path).tap do |logger|
250
261
  logger.level = log_level
251
262
  end
252
263
  end
253
264
 
265
+ def build_ecs_logger
266
+ require 'ecs_logging/logger'
267
+
268
+ ::EcsLogging::Logger.new(log_path == '-' ? $stdout : log_path).tap do |logger|
269
+ logger.level = log_level
270
+ end
271
+ end
272
+
254
273
  def app_type?(app)
255
274
  if defined?(::Rails::Application) && app.is_a?(::Rails::Application)
256
275
  return :rails
@@ -222,8 +222,14 @@ module ElasticAPM
222
222
  # rubocop:enable Metrics/CyclomaticComplexity
223
223
  # rubocop:enable Metrics/PerceivedComplexity
224
224
 
225
- def end_span
226
- return unless (span = current_spans.pop)
225
+ def end_span(span = nil)
226
+ if span
227
+ current_spans.delete(span)
228
+ else
229
+ span = current_spans.pop
230
+ end
231
+
232
+ return unless span
227
233
 
228
234
  span.done
229
235
 
@@ -77,7 +77,7 @@ module ElasticAPM
77
77
 
78
78
  def sampler_for_os(os)
79
79
  case os
80
- when :linux then Linux.new
80
+ when /^linux/ then Linux.new
81
81
  else
82
82
  warn "Disabling system metrics, unsupported host OS '#{os}'"
83
83
  disable!
@@ -29,7 +29,7 @@ module ElasticAPM
29
29
  end
30
30
 
31
31
  def self.os
32
- @platform ||= RbConfig::CONFIG.fetch('host_os', 'unknown').to_sym
32
+ @os ||= RbConfig::CONFIG.fetch('host_os', 'unknown').to_sym
33
33
  end
34
34
 
35
35
  # @api private
@@ -18,5 +18,5 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  module ElasticAPM
21
- VERSION = '4.3.0'
21
+ VERSION = '4.4.0'
22
22
  end
data/lib/elastic_apm.rb CHANGED
@@ -243,9 +243,12 @@ module ElasticAPM
243
243
 
244
244
  # Ends the current span
245
245
  #
246
+ # @param span [Span] Optional span to be ended instead of the last span
247
+ # created, useful for asynchronous environments where multiple spans are created in parallel
248
+ #
246
249
  # @return [Span]
247
- def end_span
248
- agent&.end_span
250
+ def end_span(span = nil)
251
+ agent&.end_span(span)
249
252
  end
250
253
 
251
254
  # rubocop:disable Metrics/ParameterLists
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-26 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
273
  - !ruby/object:Gem::Version
274
274
  version: '0'
275
275
  requirements: []
276
- rubygems_version: 3.0.6
276
+ rubygems_version: 3.2.22
277
277
  signing_key:
278
278
  specification_version: 4
279
279
  summary: The official Elastic APM agent for Ruby