elastic-apm 3.10.1 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/labeler-config.yml +3 -0
- data/.github/workflows/labeler.yml +16 -0
- data/.rubocop.yml +33 -4
- data/CHANGELOG.asciidoc +67 -0
- data/Gemfile +5 -6
- data/Rakefile +10 -10
- data/docs/api.asciidoc +2 -1
- data/docs/configuration.asciidoc +4 -3
- data/lib/elastic_apm.rb +14 -2
- data/lib/elastic_apm/central_config.rb +7 -2
- data/lib/elastic_apm/config.rb +51 -19
- data/lib/elastic_apm/config/log_level_map.rb +47 -0
- data/lib/elastic_apm/config/options.rb +2 -1
- data/lib/elastic_apm/config/round_float.rb +31 -0
- data/lib/elastic_apm/config/wildcard_pattern_list.rb +2 -0
- data/lib/elastic_apm/context.rb +2 -8
- data/lib/elastic_apm/graphql.rb +2 -0
- data/lib/elastic_apm/grpc.rb +3 -3
- data/lib/elastic_apm/instrumenter.rb +11 -4
- data/lib/elastic_apm/metadata.rb +3 -1
- data/lib/elastic_apm/metadata/cloud_info.rb +130 -0
- data/lib/elastic_apm/metadata/service_info.rb +2 -2
- data/lib/elastic_apm/metadata/system_info/container_info.rb +16 -5
- data/lib/elastic_apm/metrics.rb +1 -0
- data/lib/elastic_apm/metrics/cpu_mem_set.rb +1 -0
- data/lib/elastic_apm/middleware.rb +8 -3
- data/lib/elastic_apm/opentracing.rb +2 -1
- data/lib/elastic_apm/span.rb +14 -0
- data/lib/elastic_apm/span/context/db.rb +1 -1
- data/lib/elastic_apm/spies/delayed_job.rb +8 -2
- data/lib/elastic_apm/spies/dynamo_db.rb +8 -1
- data/lib/elastic_apm/spies/elasticsearch.rb +10 -2
- data/lib/elastic_apm/spies/faraday.rb +5 -2
- data/lib/elastic_apm/spies/http.rb +1 -0
- data/lib/elastic_apm/spies/mongo.rb +6 -2
- data/lib/elastic_apm/spies/net_http.rb +3 -0
- data/lib/elastic_apm/spies/rake.rb +4 -2
- data/lib/elastic_apm/spies/resque.rb +4 -2
- data/lib/elastic_apm/spies/sequel.rb +12 -1
- data/lib/elastic_apm/spies/shoryuken.rb +2 -0
- data/lib/elastic_apm/spies/sidekiq.rb +2 -0
- data/lib/elastic_apm/spies/sneakers.rb +2 -0
- data/lib/elastic_apm/spies/sucker_punch.rb +2 -0
- data/lib/elastic_apm/sql/signature.rb +4 -2
- data/lib/elastic_apm/sql/tokenizer.rb +2 -2
- data/lib/elastic_apm/stacktrace/frame.rb +1 -0
- data/lib/elastic_apm/stacktrace_builder.rb +2 -4
- data/lib/elastic_apm/trace_context.rb +1 -3
- data/lib/elastic_apm/trace_context/traceparent.rb +2 -6
- data/lib/elastic_apm/trace_context/tracestate.rb +114 -9
- data/lib/elastic_apm/transaction.rb +41 -7
- data/lib/elastic_apm/transport/connection.rb +2 -1
- data/lib/elastic_apm/transport/filters/hash_sanitizer.rb +16 -16
- data/lib/elastic_apm/transport/filters/secrets_filter.rb +35 -12
- data/lib/elastic_apm/transport/serializers.rb +9 -6
- data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +44 -4
- data/lib/elastic_apm/transport/serializers/span_serializer.rb +3 -3
- data/lib/elastic_apm/transport/serializers/transaction_serializer.rb +2 -0
- data/lib/elastic_apm/transport/user_agent.rb +3 -3
- data/lib/elastic_apm/transport/worker.rb +1 -0
- data/lib/elastic_apm/util.rb +2 -0
- data/lib/elastic_apm/util/deep_dup.rb +65 -0
- data/lib/elastic_apm/util/precision_validator.rb +46 -0
- data/lib/elastic_apm/version.rb +1 -1
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49c0c5abfddc19b97d5a0a25f7adeff62bd8ed99a1bdcb97d94ca9b3ff09134f
|
4
|
+
data.tar.gz: 4e7a68808d904181b3649cc766c075e5b575633b55a370047cd85c4eff53c5ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94af89d9a12520b2344f941b85eefdd6d0bd447dc75ac75b220b491611e0b16a47722cce78badf8f065f78cd09496d7a63d5a0e392af3ee939ed86ecef43599b
|
7
|
+
data.tar.gz: '0790d669dede1e490e290960129488264dc9661224ccb011094c1a3a5a48419ad628f5b7e83ba11ad273c8af1698e9d935cb2d6f3a823197793931f2ec27e7de'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: "Issue Labeler"
|
2
|
+
on:
|
3
|
+
issues:
|
4
|
+
types: [opened]
|
5
|
+
pull_request_target:
|
6
|
+
types: [opened]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
triage:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: AlexanderWert/issue-labeler@v2.3
|
13
|
+
with:
|
14
|
+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
15
|
+
configuration-path: .github/labeler-config.yml
|
16
|
+
enable-versioned-regex: 0
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
NewCops: enable
|
3
4
|
Exclude:
|
4
5
|
- 'elastic-apm.gemspec'
|
5
6
|
- 'vendor/**/*'
|
6
7
|
- 'bench/*'
|
7
8
|
- 'spec/support/helloworld_pb.rb'
|
8
9
|
- 'spec/support/helloworld_services_pb.rb'
|
10
|
+
- 'features/step_definitions/stepdefs.rb'
|
9
11
|
|
10
12
|
require:
|
11
13
|
- rubocop-performance
|
@@ -32,6 +34,15 @@ Lint/RescueException:
|
|
32
34
|
Lint/SuppressedException:
|
33
35
|
Enabled: false
|
34
36
|
|
37
|
+
Lint/ConstantDefinitionInBlock: # So we can define a class in an rspec block
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Lint/EmptyClass:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Lint/NoReturnInBeginEndBlocks:
|
44
|
+
Enabled: false
|
45
|
+
|
35
46
|
# Metrics /
|
36
47
|
|
37
48
|
Metrics/AbcSize:
|
@@ -104,9 +115,27 @@ Style/HashEachMethods:
|
|
104
115
|
Style/HashTransformKeys:
|
105
116
|
Enabled: true
|
106
117
|
|
107
|
-
Style/HashTransformValues:
|
108
|
-
Enabled: true
|
109
|
-
|
110
118
|
Style/FrozenStringLiteralComment:
|
111
119
|
Enabled: false
|
112
120
|
|
121
|
+
Style/StringLiterals:
|
122
|
+
Enabled: false
|
123
|
+
|
124
|
+
Style/RescueStandardError:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
Style/SoleNestedConditional:
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
Style/StringConcatenation:
|
131
|
+
Enabled: false
|
132
|
+
|
133
|
+
Style/DocumentDynamicEvalDefinition:
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
# Applies to > ruby 2.3, enable when 2.3 support is dropped
|
137
|
+
Performance/RegexpMatch:
|
138
|
+
Enabled: false
|
139
|
+
|
140
|
+
Style/HashTransformValues:
|
141
|
+
Enabled: false
|
data/CHANGELOG.asciidoc
CHANGED
@@ -35,6 +35,72 @@ endif::[]
|
|
35
35
|
[[release-notes-3.x]]
|
36
36
|
=== Ruby Agent version 3.x
|
37
37
|
|
38
|
+
[[release-notes-3.13.0]]
|
39
|
+
==== 3.13.0 (2020-12-22)
|
40
|
+
|
41
|
+
[float]
|
42
|
+
===== Fixed
|
43
|
+
|
44
|
+
- Handle invalid utf-8 byte sequences in sql summarizer and DB statement {pull}896[#896]
|
45
|
+
- Expand Kubernetes metadata discovery {pull}916[#916]
|
46
|
+
- Fix fetching cloud info on Http.rb 3.x versions {pull}919[#919]
|
47
|
+
|
48
|
+
[float]
|
49
|
+
===== Added
|
50
|
+
|
51
|
+
- Support both integer and string log levels, and extra central config values {pull}902[#902]
|
52
|
+
|
53
|
+
[float]
|
54
|
+
===== Changed
|
55
|
+
|
56
|
+
- Rename server_ca_cert to server_ca_cert_file {pull}908[#908]
|
57
|
+
|
58
|
+
[[release-notes-3.12.1]]
|
59
|
+
==== 3.12.1 (2020-11-16)
|
60
|
+
|
61
|
+
[float]
|
62
|
+
===== Fixed
|
63
|
+
|
64
|
+
- `capture_elasticsearch_queries` no longer modifies the original query {pull}894[#894]
|
65
|
+
|
66
|
+
[[release-notes-3.12.0]]
|
67
|
+
==== 3.12.0 (2020-11-10)
|
68
|
+
|
69
|
+
[float]
|
70
|
+
===== Added
|
71
|
+
|
72
|
+
- Add outcome to transactions and spans {pull}883[#883]
|
73
|
+
|
74
|
+
[[release-notes-3.11.1]]
|
75
|
+
==== 3.11.1 (2020-11-05)
|
76
|
+
|
77
|
+
[float]
|
78
|
+
===== Fixed
|
79
|
+
|
80
|
+
- Fix reporting from Kubernetes based deploys to APM Server 7.9.x {pull}885[#885]
|
81
|
+
|
82
|
+
[[release-notes-3.11.0]]
|
83
|
+
==== 3.11.0 (2020-10-27)
|
84
|
+
|
85
|
+
[float]
|
86
|
+
===== Added
|
87
|
+
|
88
|
+
- Add and read sampling info from Tracestate headers {pull}858[#858]
|
89
|
+
- Add information about cloud hosting environment if available {pull}871[#871]
|
90
|
+
|
91
|
+
[float]
|
92
|
+
===== Changed
|
93
|
+
|
94
|
+
- Align the default value of `sanitize_field_names` with other agents {pull}867[#867]
|
95
|
+
- Ensure max 4 digits of precision for `sample_rate` as per agent spec {pull}880[#880]
|
96
|
+
|
97
|
+
[float]
|
98
|
+
===== Fixed
|
99
|
+
|
100
|
+
- Fix Delayed::Job class names when used through ActiveJob {pull}869[#869]
|
101
|
+
- Fix Delayed::Job when run without the agent running {pull}874[#874]
|
102
|
+
- Fix Kubernetes related metadata {pull}882[#882]
|
103
|
+
|
38
104
|
[[release-notes-3.10.1]]
|
39
105
|
==== 3.10.1 (2020-08-26)
|
40
106
|
|
@@ -42,6 +108,7 @@ endif::[]
|
|
42
108
|
===== Fixed
|
43
109
|
|
44
110
|
- Remove secrets from cookies in errors {pull}863[#863]
|
111
|
+
- Silence deprecation warning when setting `ignore_url_patterns` to default {pull}865[#865]
|
45
112
|
|
46
113
|
[[release-notes-3.10.0]]
|
47
114
|
==== 3.10.0 (2020-08-26)
|
data/Gemfile
CHANGED
@@ -22,14 +22,11 @@ source 'https://rubygems.org'
|
|
22
22
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
23
23
|
|
24
24
|
# Tools
|
25
|
-
gem 'bootsnap', require: false
|
26
25
|
gem 'cucumber', require: false
|
27
26
|
gem 'pry'
|
28
27
|
gem 'rack-test'
|
29
28
|
gem 'rspec', '~> 3'
|
30
29
|
gem 'rspec-its'
|
31
|
-
gem 'rubocop', require: nil
|
32
|
-
gem 'rubocop-performance', require: nil
|
33
30
|
gem 'timecop'
|
34
31
|
gem 'webmock'
|
35
32
|
|
@@ -40,8 +37,10 @@ gem 'elasticsearch', require: nil
|
|
40
37
|
gem 'fakeredis', require: nil
|
41
38
|
gem 'faraday', require: nil
|
42
39
|
gem 'graphql', require: nil
|
43
|
-
|
44
|
-
gem '
|
40
|
+
if !defined?(JRUBY_VERSION) && RUBY_VERSION < '2.5'
|
41
|
+
gem 'google-protobuf', '< 3.12'
|
42
|
+
end
|
43
|
+
gem 'grpc' unless defined?(JRUBY_VERSION)
|
45
44
|
gem 'json'
|
46
45
|
gem 'json-schema', require: nil
|
47
46
|
gem 'mongo', require: nil
|
@@ -96,7 +95,7 @@ if RUBY_PLATFORM == 'java'
|
|
96
95
|
elsif frameworks_versions['rails'] =~ /^(4|5)/
|
97
96
|
gem 'sqlite3', '~> 1.3.6'
|
98
97
|
else
|
99
|
-
gem 'sqlite3'
|
98
|
+
gem 'sqlite3'
|
100
99
|
end
|
101
100
|
|
102
101
|
group :bench do
|
data/Rakefile
CHANGED
@@ -19,9 +19,9 @@
|
|
19
19
|
|
20
20
|
require 'bundler/gem_tasks'
|
21
21
|
|
22
|
-
desc
|
23
|
-
Update `3.x` branch to be at released commit and push it to GitHub.
|
24
|
-
|
22
|
+
desc 'Post release action:'\
|
23
|
+
'Update `3.x` branch to be at released commit and push it to GitHub.'
|
24
|
+
|
25
25
|
namespace :release do
|
26
26
|
task :update_branch do
|
27
27
|
`git checkout 3.x &&
|
@@ -41,11 +41,11 @@ task docs: :yard
|
|
41
41
|
task default: :spec
|
42
42
|
|
43
43
|
namespace :coverage do
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
44
|
+
desc "Collates all result sets generated by the different test runners"
|
45
|
+
task :report do
|
46
|
+
require 'simplecov'
|
47
|
+
require 'simplecov-cobertura'
|
48
|
+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
49
|
+
SimpleCov.collate Dir["coverage/matrix_results/**/.resultset.json"]
|
51
50
|
end
|
51
|
+
end
|
data/docs/api.asciidoc
CHANGED
@@ -433,6 +433,7 @@ end
|
|
433
433
|
- `name`: String
|
434
434
|
- `type`: String
|
435
435
|
- `result`: String
|
436
|
+
- `outcome`: String ('unknown', 'success', 'failure', nil)
|
436
437
|
- `trace_id`: String (readonly)
|
437
438
|
|
438
439
|
[float]
|
@@ -457,7 +458,7 @@ If your service generates the HTML page dynamically, initializing the
|
|
457
458
|
JavaScript RUM agent with the value of this method allows analyzing the time
|
458
459
|
spent in the browser vs in the backend services.
|
459
460
|
|
460
|
-
To enable the JavaScript RUM agent,
|
461
|
+
To enable the JavaScript RUM agent, initialize the RUM agent with the Ruby
|
461
462
|
agent's current transaction:
|
462
463
|
|
463
464
|
[source,html]
|
data/docs/configuration.asciidoc
CHANGED
@@ -798,12 +798,12 @@ It has to be provided in *<<config-format-duration, duration format>>*.
|
|
798
798
|
|
799
799
|
[float]
|
800
800
|
[[config-ssl-ca-cert]]
|
801
|
-
==== `
|
801
|
+
==== `server_ca_cert_file`
|
802
802
|
|
803
803
|
[options="header"]
|
804
804
|
|============
|
805
|
-
| Environment
|
806
|
-
| `
|
805
|
+
| Environment | `Config` key | Default | Example
|
806
|
+
| `ELASTIC_APM_SERVER_CA_CERT_FILE` | `server_ca_cert_file` | `nil` | `'/path/to/ca.pem'`
|
807
807
|
|============
|
808
808
|
|
809
809
|
The path to a custom CA certificate for connecting to APM Server.
|
@@ -853,6 +853,7 @@ To reduce overhead and storage requirements, you can set the sample rate to a va
|
|
853
853
|
between `0.0` and `1.0`.
|
854
854
|
We still record overall time and the result for unsampled transactions, but no
|
855
855
|
context information, tags, or spans.
|
856
|
+
Note that the sample rate will be rounded to 4 digits of precision.
|
856
857
|
|
857
858
|
[float]
|
858
859
|
[[config-use-experimental-sql-parser]]
|
data/lib/elastic_apm.rb
CHANGED
@@ -106,6 +106,7 @@ module ElasticAPM
|
|
106
106
|
# @yield [String|nil, String|nil, String|nil] The transaction, span,
|
107
107
|
# and trace ids.
|
108
108
|
# @return [String] Unless block given
|
109
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
109
110
|
def log_ids
|
110
111
|
trace_id = (current_transaction || current_span)&.trace_id
|
111
112
|
if block_given?
|
@@ -118,6 +119,7 @@ module ElasticAPM
|
|
118
119
|
ids << "trace.id=#{trace_id}" if trace_id
|
119
120
|
ids.join(' ')
|
120
121
|
end
|
122
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
121
123
|
|
122
124
|
# Start a new transaction
|
123
125
|
#
|
@@ -183,7 +185,12 @@ module ElasticAPM
|
|
183
185
|
context: context,
|
184
186
|
trace_context: trace_context
|
185
187
|
)
|
186
|
-
yield transaction
|
188
|
+
result = yield transaction
|
189
|
+
transaction&.outcome ||= Transaction::Outcome::SUCCESS
|
190
|
+
result
|
191
|
+
rescue
|
192
|
+
transaction&.outcome ||= Transaction::Outcome::FAILURE
|
193
|
+
raise
|
187
194
|
ensure
|
188
195
|
end_transaction
|
189
196
|
end
|
@@ -287,7 +294,12 @@ module ElasticAPM
|
|
287
294
|
parent: parent,
|
288
295
|
sync: sync
|
289
296
|
)
|
290
|
-
yield span
|
297
|
+
result = yield span
|
298
|
+
span&.outcome ||= Span::Outcome::SUCCESS
|
299
|
+
result
|
300
|
+
rescue
|
301
|
+
span&.outcome ||= Span::Outcome::FAILURE
|
302
|
+
raise
|
291
303
|
ensure
|
292
304
|
end_span
|
293
305
|
end
|
@@ -19,6 +19,7 @@
|
|
19
19
|
|
20
20
|
require 'elastic_apm/central_config/cache_control'
|
21
21
|
|
22
|
+
# rubocop:disable Style/AccessorGrouping
|
22
23
|
module ElasticAPM
|
23
24
|
# @api private
|
24
25
|
class CentralConfig
|
@@ -27,6 +28,7 @@ module ElasticAPM
|
|
27
28
|
# @api private
|
28
29
|
class ResponseError < InternalError
|
29
30
|
def initialize(response)
|
31
|
+
super
|
30
32
|
@response = response
|
31
33
|
end
|
32
34
|
|
@@ -72,6 +74,7 @@ module ElasticAPM
|
|
72
74
|
def fetch_config
|
73
75
|
resp = perform_request
|
74
76
|
|
77
|
+
# rubocop:disable Lint/DuplicateBranch
|
75
78
|
case resp.status
|
76
79
|
when 200..299
|
77
80
|
resp
|
@@ -82,6 +85,7 @@ module ElasticAPM
|
|
82
85
|
when 500..599
|
83
86
|
raise ServerError, resp
|
84
87
|
end
|
88
|
+
# rubocop:enable Lint/DuplicateBranch
|
85
89
|
end
|
86
90
|
|
87
91
|
def assign(update)
|
@@ -122,7 +126,7 @@ module ElasticAPM
|
|
122
126
|
assign(update)
|
123
127
|
end
|
124
128
|
|
125
|
-
if update
|
129
|
+
if update&.any?
|
126
130
|
info 'Updated config from Kibana'
|
127
131
|
debug 'Modified: %s', update.inspect
|
128
132
|
debug 'Modified original options: %s', @modified_options.inspect
|
@@ -160,7 +164,7 @@ module ElasticAPM
|
|
160
164
|
@server_url ||=
|
161
165
|
config.server_url +
|
162
166
|
'/config/v1/agents' \
|
163
|
-
"?service.name=#{config.service_name}"
|
167
|
+
"?service.name=#{CGI.escape(config.service_name)}"
|
164
168
|
end
|
165
169
|
|
166
170
|
def headers
|
@@ -182,3 +186,4 @@ module ElasticAPM
|
|
182
186
|
end
|
183
187
|
end
|
184
188
|
end
|
189
|
+
# rubocop:enable Style/AccessorGrouping
|
data/lib/elastic_apm/config.rb
CHANGED
@@ -17,9 +17,11 @@
|
|
17
17
|
|
18
18
|
# frozen_string_literal: true
|
19
19
|
|
20
|
-
require 'elastic_apm/config/options'
|
21
|
-
require 'elastic_apm/config/duration'
|
22
20
|
require 'elastic_apm/config/bytes'
|
21
|
+
require 'elastic_apm/config/duration'
|
22
|
+
require 'elastic_apm/config/log_level_map'
|
23
|
+
require 'elastic_apm/config/options'
|
24
|
+
require 'elastic_apm/config/round_float'
|
23
25
|
require 'elastic_apm/config/regexp_list'
|
24
26
|
require 'elastic_apm/config/wildcard_pattern_list'
|
25
27
|
|
@@ -30,7 +32,14 @@ module ElasticAPM
|
|
30
32
|
|
31
33
|
DEPRECATED_OPTIONS = %i[].freeze
|
32
34
|
|
33
|
-
#
|
35
|
+
# DEPRECATED: To align with other agents, change on next major bump to:
|
36
|
+
# "password, passwd, pwd, secret, *key, *token*, *session*, *credit*,
|
37
|
+
# *card*, authorization, set-cookie"
|
38
|
+
SANITIZE_FIELD_NAMES_DEFAULT =
|
39
|
+
%w[*password* *passwd* *pwd* *secret* *key* *token* *session*
|
40
|
+
*credit* *card* *authorization* *set-cookie*].freeze
|
41
|
+
|
42
|
+
# rubocop:disable Layout/LineLength, Layout/ExtraSpacing
|
34
43
|
option :config_file, type: :string, default: 'config/elastic_apm.yml'
|
35
44
|
option :server_url, type: :url, default: 'http://localhost:8200'
|
36
45
|
option :secret_token, type: :string
|
@@ -45,6 +54,7 @@ module ElasticAPM
|
|
45
54
|
option :capture_elasticsearch_queries, type: :bool, default: false
|
46
55
|
option :capture_env, type: :bool, default: true
|
47
56
|
option :central_config, type: :bool, default: true
|
57
|
+
option :cloud_provider, type: :string, default: 'auto'
|
48
58
|
option :current_user_email_method, type: :string, default: 'email'
|
49
59
|
option :current_user_id_method, type: :string, default: 'id'
|
50
60
|
option :current_user_username_method, type: :string, default: 'username'
|
@@ -66,7 +76,7 @@ module ElasticAPM
|
|
66
76
|
option :ignore_url_patterns, type: :list, default: [], converter: RegexpList.new
|
67
77
|
option :instrument, type: :bool, default: true
|
68
78
|
option :instrumented_rake_tasks, type: :list, default: []
|
69
|
-
option :log_level, type: :int, default: Logger::INFO
|
79
|
+
option :log_level, type: :int, default: Logger::INFO, converter: LogLevelMap.new
|
70
80
|
option :log_path, type: :string
|
71
81
|
option :metrics_interval, type: :int, default: '30s', converter: Duration.new
|
72
82
|
option :pool_size, type: :int, default: 1
|
@@ -76,8 +86,8 @@ module ElasticAPM
|
|
76
86
|
option :proxy_port, type: :int
|
77
87
|
option :proxy_username, type: :string
|
78
88
|
option :recording, type: :bool, default: true
|
79
|
-
option :sanitize_field_names, type: :list, default:
|
80
|
-
option :
|
89
|
+
option :sanitize_field_names, type: :list, default: SANITIZE_FIELD_NAMES_DEFAULT, converter: WildcardPatternList.new
|
90
|
+
option :server_ca_cert_file, type: :string
|
81
91
|
option :service_name, type: :string
|
82
92
|
option :service_node_name, type: :string
|
83
93
|
option :service_version, type: :string
|
@@ -89,12 +99,12 @@ module ElasticAPM
|
|
89
99
|
option :stack_trace_limit, type: :int, default: 999_999
|
90
100
|
option :transaction_ignore_urls, type: :list, default: [], converter: WildcardPatternList.new
|
91
101
|
option :transaction_max_spans, type: :int, default: 500
|
92
|
-
option :transaction_sample_rate, type: :float, default: 1.0
|
102
|
+
option :transaction_sample_rate, type: :float, default: 1.0, converter: RoundFloat.new
|
93
103
|
option :use_elastic_traceparent_header, type: :bool, default: true
|
94
104
|
option :use_legacy_sql_parser, type: :bool, default: false
|
95
105
|
option :verify_server_cert, type: :bool, default: true
|
96
106
|
|
97
|
-
# rubocop:enable
|
107
|
+
# rubocop:enable Layout/LineLength, Layout/ExtraSpacing
|
98
108
|
def initialize(options = {})
|
99
109
|
@options = load_schema
|
100
110
|
|
@@ -118,8 +128,7 @@ module ElasticAPM
|
|
118
128
|
@__root_path ||= Dir.pwd
|
119
129
|
end
|
120
130
|
|
121
|
-
attr_accessor :__view_paths, :__root_path
|
122
|
-
attr_accessor :logger
|
131
|
+
attr_accessor :__view_paths, :__root_path, :logger
|
123
132
|
|
124
133
|
attr_reader :options
|
125
134
|
|
@@ -189,6 +198,15 @@ module ElasticAPM
|
|
189
198
|
metrics_interval > 0
|
190
199
|
end
|
191
200
|
|
201
|
+
# DEPRECATED: Remove this in next major version
|
202
|
+
def sanitize_field_names=(value)
|
203
|
+
list = WildcardPatternList.new.call(value)
|
204
|
+
defaults = WildcardPatternList.new.call(SANITIZE_FIELD_NAMES_DEFAULT)
|
205
|
+
# use regex pattern for comparisons
|
206
|
+
get(:sanitize_field_names).value =
|
207
|
+
defaults.concat(list).uniq(&:pattern)
|
208
|
+
end
|
209
|
+
|
192
210
|
def span_frames_min_duration?
|
193
211
|
span_frames_min_duration != 0
|
194
212
|
end
|
@@ -207,8 +225,8 @@ module ElasticAPM
|
|
207
225
|
|
208
226
|
@ssl_context ||=
|
209
227
|
OpenSSL::SSL::SSLContext.new.tap do |context|
|
210
|
-
if
|
211
|
-
context.ca_file =
|
228
|
+
if server_ca_cert_file
|
229
|
+
context.ca_file = server_ca_cert_file
|
212
230
|
else
|
213
231
|
context.cert_store =
|
214
232
|
OpenSSL::X509::Store.new.tap(&:set_default_paths)
|
@@ -236,8 +254,10 @@ module ElasticAPM
|
|
236
254
|
end
|
237
255
|
|
238
256
|
def ignore_url_patterns=(value)
|
239
|
-
|
240
|
-
'
|
257
|
+
unless value == self.class.schema[:ignore_url_patterns][:default]
|
258
|
+
warn '[DEPRECATED] The option ignore_url_patterns is being removed. ' \
|
259
|
+
'Consider using transaction_ignore_urls instead.'
|
260
|
+
end
|
241
261
|
|
242
262
|
set(:ignore_url_patterns, value)
|
243
263
|
end
|
@@ -260,15 +280,20 @@ module ElasticAPM
|
|
260
280
|
end
|
261
281
|
alias active? active
|
262
282
|
|
283
|
+
def server_ca_cert
|
284
|
+
server_ca_cert_file
|
285
|
+
end
|
286
|
+
|
263
287
|
def disabled_instrumentations=(value)
|
264
288
|
warn '[DEPRECATED] The option disabled_instrumentations has been ' \
|
265
289
|
'renamed to disable_instrumentations to align with other agents.'
|
266
290
|
self.disable_instrumentations = value
|
267
291
|
end
|
268
292
|
|
269
|
-
def use_experimental_sql_parser=(
|
270
|
-
warn '[DEPRECATED] The new SQL parser is now the default. To use the
|
271
|
-
|
293
|
+
def use_experimental_sql_parser=(_value)
|
294
|
+
warn '[DEPRECATED] The new SQL parser is now the default. To use the ' \
|
295
|
+
'old one, use use_legacy_sql_parser and please report why you ' \
|
296
|
+
'wish to do so.'
|
272
297
|
end
|
273
298
|
|
274
299
|
def active=(value)
|
@@ -277,6 +302,12 @@ module ElasticAPM
|
|
277
302
|
self.enabled = value
|
278
303
|
end
|
279
304
|
|
305
|
+
def server_ca_cert=(value)
|
306
|
+
warn '[DEPRECATED] The option server_ca_cert has been ' \
|
307
|
+
'renamed to server_ca_cert_file to align with other agents.'
|
308
|
+
self.server_ca_cert_file = value
|
309
|
+
end
|
310
|
+
|
280
311
|
private
|
281
312
|
|
282
313
|
def load_config_file
|
@@ -295,7 +326,7 @@ module ElasticAPM
|
|
295
326
|
end
|
296
327
|
|
297
328
|
def build_logger
|
298
|
-
Logger.new(log_path == '-' ?
|
329
|
+
Logger.new(log_path == '-' ? $stdout : log_path).tap do |logger|
|
299
330
|
logger.level = log_level
|
300
331
|
end
|
301
332
|
end
|
@@ -326,7 +357,8 @@ module ElasticAPM
|
|
326
357
|
self.logger ||= ::Rails.logger
|
327
358
|
|
328
359
|
self.__root_path = ::Rails.root.to_s
|
329
|
-
self.__view_paths = app.config.paths['app/views'].existent +
|
360
|
+
self.__view_paths = app.config.paths['app/views'].existent +
|
361
|
+
[::Rails.root.to_s]
|
330
362
|
end
|
331
363
|
|
332
364
|
def rails_app_name(app)
|