elastic-apm 3.9.0 → 3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb0d3e0244586e4fe0b9c89beacd267272c0d6b8467457fcce9fde228b22742e
4
- data.tar.gz: e3279992b31d2826b6e53c8c66802c1641d30a8b8134671298280b370fa2f8e1
3
+ metadata.gz: e9c3bd29131a80fd061ecda5285eaf367f1e5643a5d6bd27b753fb566fa51799
4
+ data.tar.gz: 51b05bac2568d0c55f83444cef9f297400078a7cbcb0fef6c6ef4ce9cfdfe2fa
5
5
  SHA512:
6
- metadata.gz: a81c23c3e427e727484854c89072c17704c11fbccca518169ae75a7aa8a45bc04966226044cebcd9c1d36fe7c986053e74e1c1b0456cc6cb23bcd0207204ef9d
7
- data.tar.gz: de7d4efea50ee03db830ac3570cadc40277fd67ce630c4388f942cfbca005a8b0af72f81b0712eb38972aa7d38c01971fe4697888a75f55ffeba51b98fc51b6b
6
+ metadata.gz: db6319dbfcbe5f2429c72aebb8132bc9d1a35b4ec28aa15ecd1bb06fff4a326ad41f4753a3fb54f6f85635d9429d434f4f30b2ea23013cf7e775cb6f2d3a8a23
7
+ data.tar.gz: 32f64b02b56d214a019279b84bdaa3b04f6d72fac06d664326d0939c16c0b50a05b3654ae87a68a057c17c576679cbc726dd890cde2ac1068dd7a0fbbb05b030
@@ -35,9 +35,28 @@ endif::[]
35
35
  [[release-notes-3.x]]
36
36
  === Ruby Agent version 3.x
37
37
 
38
+ [[release-notes-3.10.0]]
39
+ ==== 3.10.0 (2020-08-26)
40
+
41
+ [float]
42
+ ===== Added
43
+
44
+ - Config option `transaction_ignore_urls` to replace `ignore_url_patterns` {pull}844[#844]
45
+ - Prepend `(?-i)` to patterns to make them case-sensitive {pull}846[#846]
46
+
47
+ [float]
48
+ ===== Fixed
49
+
50
+ - Reverted {pull}839[#839]
51
+ - Improved Kubernetes pod ID detection {pull}859[#859]
52
+
38
53
  [[release-notes-3.9.0]]
39
54
  ==== 3.9.0 (2020-08-04)
40
55
 
56
+ [float]
57
+ ===== Fixed
58
+ - Scrub request body of illegal UTF-8 characters {pull}832[#832]
59
+
41
60
  [float]
42
61
  ===== Added
43
62
 
data/Gemfile CHANGED
@@ -42,6 +42,7 @@ gem 'faraday', require: nil
42
42
  gem 'graphql', require: nil
43
43
  gem 'google-protobuf', '< 3.12' if !defined?(JRUBY_VERSION) && RUBY_VERSION < '2.5'
44
44
  gem 'grpc' if !defined?(JRUBY_VERSION)
45
+ gem 'json'
45
46
  gem 'json-schema', require: nil
46
47
  gem 'mongo', require: nil
47
48
  gem 'opentracing', require: nil
@@ -87,6 +87,7 @@ module ElasticAPM
87
87
  option :source_lines_span_library_frames, type: :int, default: 0
88
88
  option :span_frames_min_duration, type: :float, default: '5ms', converter: Duration.new(default_unit: 'ms')
89
89
  option :stack_trace_limit, type: :int, default: 999_999
90
+ option :transaction_ignore_urls, type: :list, default: [], converter: WildcardPatternList.new
90
91
  option :transaction_max_spans, type: :int, default: 500
91
92
  option :transaction_sample_rate, type: :float, default: 1.0
92
93
  option :use_elastic_traceparent_header, type: :bool, default: true
@@ -234,6 +235,13 @@ module ElasticAPM
234
235
  self.default_labels = value
235
236
  end
236
237
 
238
+ def ignore_url_patterns=(value)
239
+ warn '[DEPRECATED] The option ignore_url_patterns is being removed. ' \
240
+ 'Consider using transaction_ignore_urls instead.'
241
+
242
+ set(:ignore_url_patterns, value)
243
+ end
244
+
237
245
  def custom_key_filters=(value)
238
246
  unless value == self.class.schema[:custom_key_filters][:default]
239
247
  warn '[DEPRECATED] The option custom_key_filters is being removed. ' \
@@ -318,7 +326,7 @@ module ElasticAPM
318
326
  self.logger ||= ::Rails.logger
319
327
 
320
328
  self.__root_path = ::Rails.root.to_s
321
- self.__view_paths = ::ActionController::Base.view_paths.map(&:to_s)
329
+ self.__view_paths = app.config.paths['app/views'].existent + [::Rails.root.to_s]
322
330
  end
323
331
 
324
332
  def rails_app_name(app)
@@ -36,12 +36,22 @@ module ElasticAPM
36
36
  private
37
37
 
38
38
  def convert(str)
39
+ case_sensitive = false
40
+
41
+ if str.start_with?('(?-i)')
42
+ str = str.gsub(/^\(\?-\i\)/, '')
43
+ case_sensitive = true
44
+ end
45
+
39
46
  parts =
40
47
  str.chars.each_with_object([]) do |char, arr|
41
48
  arr << (char == '*' ? '.*' : Regexp.escape(char))
42
49
  end
43
50
 
44
- Regexp.new('\A' + parts.join + '\Z', Regexp::IGNORECASE)
51
+ Regexp.new(
52
+ '\A' + parts.join + '\Z',
53
+ case_sensitive ? nil : Regexp::IGNORECASE
54
+ )
45
55
  end
46
56
  end
47
57
 
@@ -76,7 +76,7 @@ module ElasticAPM
76
76
  else
77
77
  body = req.body.read
78
78
  req.body.rewind
79
- body.byteslice(0, MAX_BODY_LENGTH).force_encoding('utf-8')
79
+ body.byteslice(0, MAX_BODY_LENGTH).force_encoding('utf-8').scrub
80
80
  end
81
81
  end
82
82
 
@@ -24,7 +24,7 @@ module ElasticAPM
24
24
  def initialize(config)
25
25
  @config = config
26
26
 
27
- @hostname = @config.hostname || `hostname`.chomp
27
+ @hostname = @config.hostname || self.class.system_hostname
28
28
  @architecture = gem_platform.cpu
29
29
  @platform = gem_platform.os
30
30
 
@@ -35,11 +35,13 @@ module ElasticAPM
35
35
 
36
36
  attr_reader :hostname, :architecture, :platform, :container, :kubernetes
37
37
 
38
- private
39
-
40
38
  def gem_platform
41
39
  @gem_platform ||= Gem::Platform.local
42
40
  end
41
+
42
+ def self.system_hostname
43
+ @system_hostname ||= `hostname`.chomp
44
+ end
43
45
  end
44
46
  end
45
47
  end
@@ -81,8 +81,14 @@ module ElasticAPM
81
81
  ENV.fetch('KUBERNETES_POD_UID', kubernetes_pod_uid)
82
82
  end
83
83
 
84
- CONTAINER_ID_REGEX = /^[0-9A-Fa-f]{64}$/.freeze
85
- KUBEPODS_REGEX = %r{(?:^/kubepods/[^/]+/pod([^/]+)$)|(?:^/kubepods\.slice/kubepods-[^/]+\.slice/kubepods-[^/]+-pod([^/]+)\.slice$)}.freeze # rubocop:disable Metrics/LineLength
84
+ CONTAINER_ID_REGEXES = [
85
+ %r{^[[:xdigit:]]{64}$},
86
+ %r{^[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4,}$}
87
+ ]
88
+ KUBEPODS_REGEXES = [
89
+ %r{(?:^/kubepods[^\s]*/pod([^/]+)$)},
90
+ %r{(?:^/kubepods\.slice/kubepods-[^/]+\.slice/kubepods-[^/]+-pod([^/]+)\.slice$)}
91
+ ]
86
92
  SYSTEMD_SCOPE_SUFFIX = '.scope'
87
93
 
88
94
  # rubocop:disable Metrics/PerceivedComplexity
@@ -118,18 +124,36 @@ module ElasticAPM
118
124
  end
119
125
  end
120
126
 
121
- if (kubepods_match = KUBEPODS_REGEX.match(directory))
127
+ if (kubepods_match = match_kubepods(directory))
122
128
  pod_id = kubepods_match[1] || kubepods_match[2]
123
129
 
124
130
  self.container_id = container_id
125
131
  self.kubernetes_pod_uid = pod_id
126
- elsif CONTAINER_ID_REGEX.match(container_id)
132
+ elsif match_container(container_id)
127
133
  self.container_id = container_id
128
134
  end
129
135
  end
130
136
  end
131
137
  # rubocop:enable Metrics/PerceivedComplexity
132
138
  # rubocop:enable Metrics/CyclomaticComplexity
139
+
140
+ def match_kubepods(directory)
141
+ KUBEPODS_REGEXES.each do |r|
142
+ next unless (match = r.match(directory))
143
+ return match
144
+ end
145
+
146
+ nil
147
+ end
148
+
149
+ def match_container(container_id)
150
+ CONTAINER_ID_REGEXES.each do |r|
151
+ next unless (match = r.match(container_id))
152
+ return match
153
+ end
154
+
155
+ nil
156
+ end
133
157
  end
134
158
  end
135
159
  end
@@ -59,9 +59,15 @@ module ElasticAPM
59
59
  end
60
60
 
61
61
  def path_ignored?(env)
62
- config.ignore_url_patterns.any? do |r|
63
- env['PATH_INFO'].match r
62
+ return true if config.ignore_url_patterns.any? do |r|
63
+ r.match(env['PATH_INFO'])
64
64
  end
65
+
66
+ return true if config.transaction_ignore_urls.any? do |r|
67
+ r.match(env['PATH_INFO'])
68
+ end
69
+
70
+ false
65
71
  end
66
72
 
67
73
  def start_transaction(env)
@@ -97,11 +97,12 @@ module ElasticAPM
97
97
 
98
98
  def done(clock_end: Util.monotonic_micros)
99
99
  stop clock_end
100
+ self
101
+ end
100
102
 
103
+ def prepare_for_serialization!
101
104
  build_stacktrace! if should_build_stacktrace?
102
105
  self.original_backtrace = nil # release original
103
-
104
- self
105
106
  end
106
107
 
107
108
  def stopped?
@@ -77,6 +77,10 @@ module ElasticAPM
77
77
  private
78
78
 
79
79
  def serialize_and_filter(resource)
80
+ if resource.respond_to?(:prepare_for_serialization!)
81
+ resource.prepare_for_serialization!
82
+ end
83
+
80
84
  serialized = serializers.serialize(resource)
81
85
 
82
86
  # if a filter returns nil, it means skip the event
@@ -18,5 +18,5 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  module ElasticAPM
21
- VERSION = '3.9.0'
21
+ VERSION = '3.10.0'
22
22
  end
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: 3.9.0
4
+ version: 3.10.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: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2020-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby