elastic-apm 2.6.1 → 2.7.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.
Potentially problematic release.
This version of elastic-apm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/CHANGELOG.md +18 -1
- data/Jenkinsfile +3 -7
- data/README.md +1 -1
- data/docs/api.asciidoc +6 -0
- data/docs/configuration.asciidoc +16 -4
- data/docs/getting-started-rack.asciidoc +1 -1
- data/docs/getting-started-rails.asciidoc +1 -1
- data/docs/index.asciidoc +2 -0
- data/docs/release-notes.asciidoc +4 -0
- data/lib/elastic_apm/agent.rb +8 -3
- data/lib/elastic_apm/config.rb +4 -1
- data/lib/elastic_apm/error_builder.rb +2 -0
- data/lib/elastic_apm/instrumenter.rb +3 -1
- data/lib/elastic_apm/metadata/system_info.rb +2 -2
- data/lib/elastic_apm/metadata/system_info/container_info.rb +27 -23
- data/lib/elastic_apm/metrics.rb +13 -2
- data/lib/elastic_apm/railtie.rb +8 -3
- data/lib/elastic_apm/spies/faraday.rb +9 -1
- data/lib/elastic_apm/transport/base.rb +108 -31
- data/lib/elastic_apm/transport/connection.rb +77 -153
- data/lib/elastic_apm/transport/connection/http.rb +116 -0
- data/lib/elastic_apm/transport/connection/proxy_pipe.rb +68 -0
- data/lib/elastic_apm/transport/filters/secrets_filter.rb +1 -0
- data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +2 -1
- data/lib/elastic_apm/transport/worker.rb +14 -19
- data/lib/elastic_apm/util.rb +4 -2
- data/lib/elastic_apm/util/throttle.rb +35 -0
- data/lib/elastic_apm/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37a03e42bbce98f7206216314854dbe171c6964bf757fc9e25f2d990af922d38
|
4
|
+
data.tar.gz: c4be66c848b4345e8594a178b8fc2738f585bbcc772a81943734a6f1ad1c8b45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81b744b6d0ff9aa3fa1f38b105a9aab42b98da5f15f173e3542882b81b860e3b02139090125f36c429032deba1e638d263469e3bdbf16f060eabf8da7edfcc25
|
7
|
+
data.tar.gz: 3070245854f3547326143d7e494f6cee9851985b5d8f2b56d07b914461cdb8f9ebb255d0466054e923b65dc77b21eb142beb477b00b4f6b14d4773eefb24ca42
|
data/.rubocop.yml
CHANGED
@@ -5,9 +5,15 @@ AllCops:
|
|
5
5
|
- 'vendor/**/*'
|
6
6
|
- 'bench/*'
|
7
7
|
|
8
|
+
Layout/AlignArguments:
|
9
|
+
EnforcedStyle: with_fixed_indentation
|
10
|
+
|
8
11
|
Layout/AlignParameters:
|
9
12
|
EnforcedStyle: with_fixed_indentation
|
10
13
|
|
14
|
+
Layout/IndentFirstParameter:
|
15
|
+
Enabled: false
|
16
|
+
|
11
17
|
Layout/AlignHash:
|
12
18
|
Exclude:
|
13
19
|
- 'Gemfile'
|
@@ -21,6 +27,9 @@ Lint/RescueException:
|
|
21
27
|
Lint/HandleExceptions:
|
22
28
|
Enabled: false
|
23
29
|
|
30
|
+
Lint/NonLocalExitFromIterator:
|
31
|
+
Enabled: false
|
32
|
+
|
24
33
|
Metrics/BlockLength:
|
25
34
|
Exclude:
|
26
35
|
- 'spec/**/*.rb'
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,24 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## 2.
|
7
|
+
## 2.7.0 (2019-05-07)
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Added `disable_start_message` for those wanting complete silence on boot ([#397](https://github.com/elastic/apm-agent-ruby/pull/397))
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
- Attempt to strip secrets from `request.env` ([#410](https://github.com/elastic/apm-agent-ruby/pull/410))
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
|
19
|
+
- Rewritten most of the internal transport code, streaming events to APM Server ([#372](https://github.com/elastic/apm-agent-ruby/pull/372))
|
20
|
+
- Re-added `default_tags` ([#395](https://github.com/elastic/apm-agent-ruby/pull/395))
|
21
|
+
- A bug in the Faraday spy when disabling the Net::HTTP spy ([#396](https://github.com/elastic/apm-agent-ruby/pull/396))
|
22
|
+
- Fix disabling the ActionDispatch spy ([#399](https://github.com/elastic/apm-agent-ruby/pull/399))
|
23
|
+
|
24
|
+
## 2.6.1 (2019-03-28)
|
8
25
|
|
9
26
|
### Fixed
|
10
27
|
|
data/Jenkinsfile
CHANGED
@@ -17,6 +17,7 @@ pipeline {
|
|
17
17
|
PIPELINE_LOG_LEVEL='INFO'
|
18
18
|
NOTIFY_TO = credentials('notify-to')
|
19
19
|
JOB_GCS_BUCKET = credentials('gcs-bucket')
|
20
|
+
CODECOV_SECRET = 'secret/apm-team/ci/apm-agent-ruby-codecov'
|
20
21
|
}
|
21
22
|
options {
|
22
23
|
timeout(time: 2, unit: 'HOURS')
|
@@ -82,9 +83,6 @@ pipeline {
|
|
82
83
|
beforeAgent true
|
83
84
|
allOf {
|
84
85
|
anyOf {
|
85
|
-
not {
|
86
|
-
changeRequest()
|
87
|
-
}
|
88
86
|
branch 'master'
|
89
87
|
branch "\\d+\\.\\d+"
|
90
88
|
branch "v\\d?"
|
@@ -139,9 +137,6 @@ pipeline {
|
|
139
137
|
beforeAgent true
|
140
138
|
allOf {
|
141
139
|
anyOf {
|
142
|
-
not {
|
143
|
-
changeRequest()
|
144
|
-
}
|
145
140
|
branch 'master'
|
146
141
|
branch "\\d+\\.\\d+"
|
147
142
|
branch "v\\d?"
|
@@ -214,7 +209,8 @@ class RubyParallelTaskGenerator extends DefaultParallelTaskGenerator {
|
|
214
209
|
steps.junit(allowEmptyResults: false,
|
215
210
|
keepLongStdio: true,
|
216
211
|
testResults: "**/spec/ruby-agent-junit.xml")
|
217
|
-
steps.codecov(repo: 'apm-agent-ruby', basedir: "${steps.env.BASE_DIR}"
|
212
|
+
steps.codecov(repo: 'apm-agent-ruby', basedir: "${steps.env.BASE_DIR}",
|
213
|
+
secret: "${steps.env.CODECOV_SECRET}")
|
218
214
|
}
|
219
215
|
}
|
220
216
|
}
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# elastic-apm
|
2
2
|
## Elastic APM agent for ♦️Ruby
|
3
3
|
|
4
|
-
[](https://apm-ci.elastic.co/job/apm-agent-ruby/apm-agent-ruby-mbp/master) [](https://rubygems.org/gems/elastic-apm) [](https://codecov.io/gh/elastic/apm-agent-ruby)
|
4
|
+
[](https://apm-ci.elastic.co/job/apm-agent-ruby/job/apm-agent-ruby-mbp/job/master/) [](https://rubygems.org/gems/elastic-apm) [](https://codecov.io/gh/elastic/apm-agent-ruby)
|
5
5
|
|
6
6
|
The official Rubygem for [Elastic][] [APM][].
|
7
7
|
|
data/docs/api.asciidoc
CHANGED
@@ -244,6 +244,9 @@ Add a tag to the current transaction.
|
|
244
244
|
Tags are basic key-value pairs that are indexed in your Elasticsearch database
|
245
245
|
and therefore searchable.
|
246
246
|
|
247
|
+
TIP: Before using custom tags, ensure you understand the different types of
|
248
|
+
{apm-overview-ref-v}/metadata.html[metadata] that are available.
|
249
|
+
|
247
250
|
[source,ruby]
|
248
251
|
----
|
249
252
|
before_action do
|
@@ -268,6 +271,9 @@ Add custom context to the current transaction.
|
|
268
271
|
Use this to further specify a context that will help you track or diagnose what's
|
269
272
|
going on inside your app.
|
270
273
|
|
274
|
+
TIP: Before using custom context, ensure you understand the different types of
|
275
|
+
{apm-overview-ref-v}/metadata.html[metadata] that are available.
|
276
|
+
|
271
277
|
If called several times during a transaction the custom context will be destructively
|
272
278
|
merged with `merge!`.
|
273
279
|
|
data/docs/configuration.asciidoc
CHANGED
@@ -248,12 +248,22 @@ WARNING: Be aware that tags are indexed in Elasticsearch. Using too many unique
|
|
248
248
|
[[config-disable-send]]
|
249
249
|
==== `disable_send`
|
250
250
|
|============
|
251
|
-
| Environment
|
252
|
-
|
|
251
|
+
| Environment | `Config` key | Default
|
252
|
+
| `ELASTIC_APM_DISABLE_SEND` | `disable_send` | `false`
|
253
253
|
|============
|
254
254
|
|
255
255
|
Disables sending payloads to APM Server.
|
256
256
|
|
257
|
+
[float]
|
258
|
+
[[config-disable-start-message]]
|
259
|
+
==== `disable_start_message`
|
260
|
+
|============
|
261
|
+
| Environment | `Config` key | Default
|
262
|
+
| `ELASTIC_APM_DISABLE_START_MESSAGE` | `disable_start_message` | `false`
|
263
|
+
|============
|
264
|
+
|
265
|
+
Disables the agent's startup message announcing itself.
|
266
|
+
|
257
267
|
[float]
|
258
268
|
[[config-disabled-spies]]
|
259
269
|
==== `disabled_spies`
|
@@ -458,8 +468,8 @@ the worker pool size might help.
|
|
458
468
|
|
459
469
|
[options="header"]
|
460
470
|
|============
|
461
|
-
| Environment
|
462
|
-
|
|
471
|
+
| Environment | `Config` key | Default | Example
|
472
|
+
| `ELASTIC_APM_PROXY_ADDRESS` | `proxy_address` | `nil` | `"example.com"`
|
463
473
|
|============
|
464
474
|
|
465
475
|
An address to use as a proxy for the HTTP client.
|
@@ -472,6 +482,8 @@ Options available are:
|
|
472
482
|
- `proxy_port`
|
473
483
|
- `proxy_username`
|
474
484
|
|
485
|
+
There are also `ENV` version of these following the same pattern of putting `ELASTIC_APM_` in front.
|
486
|
+
|
475
487
|
See https://github.com/httprb/http/wiki/Proxy-Support[Http.rb's docs].
|
476
488
|
|
477
489
|
[float]
|
data/docs/index.asciidoc
CHANGED
data/lib/elastic_apm/agent.rb
CHANGED
@@ -33,7 +33,7 @@ module ElasticAPM
|
|
33
33
|
|
34
34
|
unless config.active?
|
35
35
|
config.logger.debug format(
|
36
|
-
|
36
|
+
"%sAgent disabled with `active: false'",
|
37
37
|
Logging::PREFIX
|
38
38
|
)
|
39
39
|
return
|
@@ -75,26 +75,31 @@ module ElasticAPM
|
|
75
75
|
attr_reader :config, :transport, :instrumenter,
|
76
76
|
:stacktrace_builder, :context_builder, :error_builder, :metrics
|
77
77
|
|
78
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
78
79
|
def start
|
79
|
-
|
80
|
+
unless config.disable_start_message
|
81
|
+
info '[%s] Starting agent, reporting to %s', VERSION, config.server_url
|
82
|
+
end
|
80
83
|
|
81
84
|
transport.start
|
82
85
|
instrumenter.start
|
83
86
|
metrics.start
|
84
87
|
|
85
88
|
config.enabled_spies.each do |lib|
|
89
|
+
debug "Requiring spy: #{lib}"
|
86
90
|
require "elastic_apm/spies/#{lib}"
|
87
91
|
end
|
88
92
|
|
89
93
|
self
|
90
94
|
end
|
95
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
91
96
|
|
92
97
|
def stop
|
93
98
|
debug 'Stopping agent'
|
94
99
|
|
100
|
+
metrics.stop
|
95
101
|
instrumenter.stop
|
96
102
|
transport.stop
|
97
|
-
metrics.stop
|
98
103
|
|
99
104
|
self
|
100
105
|
end
|
data/lib/elastic_apm/config.rb
CHANGED
@@ -32,6 +32,7 @@ module ElasticAPM
|
|
32
32
|
custom_key_filters: [],
|
33
33
|
default_tags: {},
|
34
34
|
disable_send: false,
|
35
|
+
disable_start_message: false,
|
35
36
|
disabled_spies: %w[json],
|
36
37
|
environment: ENV['RAILS_ENV'] || ENV['RACK_ENV'],
|
37
38
|
filter_exception_types: [],
|
@@ -72,6 +73,7 @@ module ElasticAPM
|
|
72
73
|
'ELASTIC_APM_DEFAULT_TAGS' => [:dict, 'default_tags'],
|
73
74
|
'ELASTIC_APM_DISABLED_SPIES' => [:list, 'disabled_spies'],
|
74
75
|
'ELASTIC_APM_DISABLE_SEND' => [:bool, 'disable_send'],
|
76
|
+
'ELASTIC_APM_DISABLE_START_MESSAGE' => [:bool, 'disable_start_message'],
|
75
77
|
'ELASTIC_APM_ENVIRONMENT' => 'environment',
|
76
78
|
'ELASTIC_APM_FRAMEWORK_NAME' => 'framework_name',
|
77
79
|
'ELASTIC_APM_FRAMEWORK_VERSION' => 'framework_version',
|
@@ -151,6 +153,7 @@ module ElasticAPM
|
|
151
153
|
attr_accessor :current_user_username_method
|
152
154
|
attr_accessor :default_tags
|
153
155
|
attr_accessor :disable_send
|
156
|
+
attr_accessor :disable_start_message
|
154
157
|
attr_accessor :disabled_spies
|
155
158
|
attr_accessor :environment
|
156
159
|
attr_accessor :filter_exception_types
|
@@ -197,6 +200,7 @@ module ElasticAPM
|
|
197
200
|
alias :capture_headers? :capture_headers
|
198
201
|
alias :capture_env? :capture_env
|
199
202
|
alias :disable_send? :disable_send
|
203
|
+
alias :disable_start_message? :disable_start_message
|
200
204
|
alias :http_compression? :http_compression
|
201
205
|
alias :instrument? :instrument
|
202
206
|
alias :verify_server_cert? :verify_server_cert
|
@@ -243,7 +247,6 @@ module ElasticAPM
|
|
243
247
|
# rubocop:disable Metrics/MethodLength
|
244
248
|
def available_spies
|
245
249
|
%w[
|
246
|
-
action_dispatch
|
247
250
|
delayed_job
|
248
251
|
elasticsearch
|
249
252
|
faraday
|
@@ -11,6 +11,8 @@ module ElasticAPM
|
|
11
11
|
error = Error.new context: context || Context.new
|
12
12
|
error.exception = Error::Exception.new(exception, handled: handled)
|
13
13
|
|
14
|
+
Util.reverse_merge!(error.context.tags, @agent.config.default_tags)
|
15
|
+
|
14
16
|
if exception.backtrace
|
15
17
|
add_stacktrace error, :exception, exception.backtrace
|
16
18
|
end
|
@@ -63,6 +63,7 @@ module ElasticAPM
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def subscriber=(subscriber)
|
66
|
+
debug 'Registering subscriber'
|
66
67
|
@subscriber = subscriber
|
67
68
|
@subscriber.register!
|
68
69
|
end
|
@@ -99,7 +100,8 @@ module ElasticAPM
|
|
99
100
|
type,
|
100
101
|
context: context,
|
101
102
|
trace_context: trace_context,
|
102
|
-
sampled: sampled
|
103
|
+
sampled: sampled,
|
104
|
+
tags: config.default_tags
|
103
105
|
)
|
104
106
|
|
105
107
|
transaction.start
|
@@ -13,10 +13,10 @@ module ElasticAPM
|
|
13
13
|
|
14
14
|
container_info = ContainerInfo.read!
|
15
15
|
@container = container_info.container
|
16
|
-
@
|
16
|
+
@kubernetes = container_info.kubernetes
|
17
17
|
end
|
18
18
|
|
19
|
-
attr_reader :hostname, :architecture, :platform, :container, :
|
19
|
+
attr_reader :hostname, :architecture, :platform, :container, :kubernetes
|
20
20
|
|
21
21
|
private
|
22
22
|
|
@@ -5,10 +5,10 @@ module ElasticAPM
|
|
5
5
|
class SystemInfo
|
6
6
|
# @api private
|
7
7
|
class ContainerInfo
|
8
|
-
CGROUP_PATH = '/proc/
|
8
|
+
CGROUP_PATH = '/proc/self/cgroup'
|
9
9
|
|
10
|
-
attr_accessor :container_id, :
|
11
|
-
:
|
10
|
+
attr_accessor :container_id, :kubernetes_namespace,
|
11
|
+
:kubernetes_node_name, :kubernetes_pod_name, :kubernetes_pod_uid
|
12
12
|
|
13
13
|
def initialize(cgroup_path: CGROUP_PATH)
|
14
14
|
@cgroup_path = cgroup_path
|
@@ -34,32 +34,36 @@ module ElasticAPM
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
# rubocop:disable Metrics/MethodLength
|
38
|
+
def kubernetes
|
39
|
+
@kubernetes =
|
39
40
|
begin
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
kubernetes = {
|
42
|
+
namespace: kubernetes_namespace,
|
43
|
+
node: { name: kubernetes_node_name },
|
44
|
+
pod: {
|
45
|
+
name: kubernetes_pod_name,
|
46
|
+
uid: kubernetes_pod_uid
|
47
|
+
}
|
48
|
+
}
|
49
|
+
return nil if kubernetes.values.all?(&:nil?)
|
50
|
+
|
51
|
+
kubernetes
|
49
52
|
end
|
50
53
|
end
|
54
|
+
# rubocop:enable Metrics/MethodLength
|
51
55
|
|
52
56
|
private
|
53
57
|
|
54
58
|
def read_from_env!
|
55
|
-
self.
|
56
|
-
ENV.fetch('KUBERNETES_NAMESPACE',
|
57
|
-
self.
|
58
|
-
ENV.fetch('KUBERNETES_NODE_NAME',
|
59
|
-
self.
|
60
|
-
ENV.fetch('KUBERNETES_POD_NAME',
|
61
|
-
self.
|
62
|
-
ENV.fetch('KUBERNETES_POD_UID',
|
59
|
+
self.kubernetes_namespace =
|
60
|
+
ENV.fetch('KUBERNETES_NAMESPACE', kubernetes_namespace)
|
61
|
+
self.kubernetes_node_name =
|
62
|
+
ENV.fetch('KUBERNETES_NODE_NAME', kubernetes_node_name)
|
63
|
+
self.kubernetes_pod_name =
|
64
|
+
ENV.fetch('KUBERNETES_POD_NAME', kubernetes_pod_name)
|
65
|
+
self.kubernetes_pod_uid =
|
66
|
+
ENV.fetch('KUBERNETES_POD_UID', kubernetes_pod_uid)
|
63
67
|
end
|
64
68
|
|
65
69
|
CONTAINER_ID_REGEX = /^[0-9A-Fa-f]{64}$/.freeze
|
@@ -103,7 +107,7 @@ module ElasticAPM
|
|
103
107
|
pod_id = kubepods_match[1] || kubepods_match[2]
|
104
108
|
|
105
109
|
self.container_id = container_id
|
106
|
-
self.
|
110
|
+
self.kubernetes_pod_uid = pod_id
|
107
111
|
elsif CONTAINER_ID_REGEX.match(container_id)
|
108
112
|
self.container_id = container_id
|
109
113
|
end
|
data/lib/elastic_apm/metrics.rb
CHANGED
@@ -24,7 +24,10 @@ module ElasticAPM
|
|
24
24
|
def initialize(config, tags: nil, &block)
|
25
25
|
@config = config
|
26
26
|
@tags = tags
|
27
|
-
@samplers = [CpuMem].map
|
27
|
+
@samplers = [CpuMem].map do |kls|
|
28
|
+
debug "Adding metrics collector '#{kls}'"
|
29
|
+
kls.new(config)
|
30
|
+
end
|
28
31
|
@callback = block
|
29
32
|
end
|
30
33
|
|
@@ -32,7 +35,12 @@ module ElasticAPM
|
|
32
35
|
|
33
36
|
# rubocop:disable Metrics/MethodLength
|
34
37
|
def start
|
35
|
-
|
38
|
+
unless config.collect_metrics?
|
39
|
+
debug 'Skipping metrics'
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
debug 'Starting metrics'
|
36
44
|
|
37
45
|
@timer_task = Concurrent::TimerTask.execute(
|
38
46
|
run_now: true,
|
@@ -40,6 +48,7 @@ module ElasticAPM
|
|
40
48
|
timeout_interval: TIMEOUT_INTERVAL
|
41
49
|
) do
|
42
50
|
begin
|
51
|
+
debug 'Collecting metrics'
|
43
52
|
collect_and_send
|
44
53
|
true
|
45
54
|
rescue StandardError => e
|
@@ -56,6 +65,8 @@ module ElasticAPM
|
|
56
65
|
def stop
|
57
66
|
return unless running?
|
58
67
|
|
68
|
+
debug 'Stopping metrics'
|
69
|
+
|
59
70
|
@timer_task.shutdown
|
60
71
|
@running = false
|
61
72
|
end
|