elastic-apm 3.2.0 → 3.3.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 +4 -4
- data/.ci/.jenkins_exclude.yml +8 -1
- data/.ci/.jenkins_ruby.yml +1 -0
- data/.ci/Jenkinsfile +64 -31
- data/.github/workflows/main.yml +14 -0
- data/.pre-commit-config.yaml +1 -5
- data/.rubocop.yml +35 -29
- data/CHANGELOG.asciidoc +20 -4
- data/Gemfile +1 -0
- data/README.md +2 -2
- data/bin/dev +1 -1
- data/bin/run-tests +3 -0
- data/docs/api.asciidoc +0 -29
- data/docs/configuration.asciidoc +11 -0
- data/docs/context.asciidoc +4 -4
- data/lib/elastic_apm.rb +5 -9
- data/lib/elastic_apm/agent.rb +0 -9
- data/lib/elastic_apm/central_config.rb +10 -10
- data/lib/elastic_apm/central_config/cache_control.rb +1 -1
- data/lib/elastic_apm/config.rb +4 -11
- data/lib/elastic_apm/config/options.rb +2 -4
- data/lib/elastic_apm/config/wildcard_pattern_list.rb +35 -0
- data/lib/elastic_apm/context_builder.rb +0 -2
- data/lib/elastic_apm/error.rb +1 -1
- data/lib/elastic_apm/error/exception.rb +2 -2
- data/lib/elastic_apm/error_builder.rb +0 -2
- data/lib/elastic_apm/grape.rb +0 -3
- data/lib/elastic_apm/instrumenter.rb +3 -13
- data/lib/elastic_apm/metadata/service_info.rb +0 -5
- data/lib/elastic_apm/metadata/system_info/container_info.rb +4 -6
- data/lib/elastic_apm/metrics.rb +0 -3
- data/lib/elastic_apm/metrics/cpu_mem_set.rb +0 -10
- data/lib/elastic_apm/metrics/metric.rb +6 -2
- data/lib/elastic_apm/metrics/set.rb +4 -4
- data/lib/elastic_apm/metrics/span_scoped_set.rb +1 -1
- data/lib/elastic_apm/metrics/transaction_set.rb +0 -2
- data/lib/elastic_apm/metrics/vm_set.rb +0 -3
- data/lib/elastic_apm/middleware.rb +0 -2
- data/lib/elastic_apm/normalizers/grape/endpoint_run.rb +2 -1
- data/lib/elastic_apm/normalizers/rails/active_record.rb +1 -1
- data/lib/elastic_apm/opentracing.rb +6 -15
- data/lib/elastic_apm/rails.rb +2 -5
- data/lib/elastic_apm/sinatra.rb +1 -1
- data/lib/elastic_apm/span.rb +2 -2
- data/lib/elastic_apm/span/context.rb +17 -1
- data/lib/elastic_apm/spies/elasticsearch.rb +0 -3
- data/lib/elastic_apm/spies/faraday.rb +2 -4
- data/lib/elastic_apm/spies/http.rb +0 -3
- data/lib/elastic_apm/spies/mongo.rb +10 -5
- data/lib/elastic_apm/spies/net_http.rb +1 -4
- data/lib/elastic_apm/spies/rake.rb +0 -2
- data/lib/elastic_apm/spies/sequel.rb +0 -2
- data/lib/elastic_apm/spies/sidekiq.rb +2 -6
- data/lib/elastic_apm/spies/sinatra.rb +0 -2
- data/lib/elastic_apm/stacktrace/frame.rb +0 -3
- data/lib/elastic_apm/stacktrace_builder.rb +0 -2
- data/lib/elastic_apm/subscriber.rb +2 -3
- data/lib/elastic_apm/trace_context.rb +0 -3
- data/lib/elastic_apm/transaction.rb +2 -2
- data/lib/elastic_apm/transport/base.rb +0 -6
- data/lib/elastic_apm/transport/connection.rb +1 -4
- data/lib/elastic_apm/transport/connection/http.rb +0 -2
- data/lib/elastic_apm/transport/filters.rb +1 -1
- data/lib/elastic_apm/transport/filters/secrets_filter.rb +1 -3
- data/lib/elastic_apm/transport/serializers.rb +0 -3
- data/lib/elastic_apm/transport/serializers/context_serializer.rb +0 -2
- data/lib/elastic_apm/transport/serializers/error_serializer.rb +0 -2
- data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +0 -2
- data/lib/elastic_apm/transport/serializers/metricset_serializer.rb +0 -2
- data/lib/elastic_apm/transport/serializers/span_serializer.rb +0 -3
- data/lib/elastic_apm/transport/serializers/transaction_serializer.rb +0 -2
- data/lib/elastic_apm/transport/worker.rb +10 -6
- data/lib/elastic_apm/util.rb +1 -1
- data/lib/elastic_apm/version.rb +1 -1
- metadata +5 -5
- data/.ci/bin/check_paths_for_matches.py +0 -80
- data/.hound.yml +0 -2
data/lib/elastic_apm/grape.rb
CHANGED
@@ -7,8 +7,6 @@ module ElasticAPM
|
|
7
7
|
# Module for starting the ElasticAPM agent and hooking into Grape.
|
8
8
|
module Grape
|
9
9
|
extend self
|
10
|
-
|
11
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
12
10
|
# Start the ElasticAPM agent and hook into Grape.
|
13
11
|
#
|
14
12
|
# @param app [Grape::API] A Grape app.
|
@@ -27,7 +25,6 @@ module ElasticAPM
|
|
27
25
|
config.logger.error format('Failed to start: %s', e.message)
|
28
26
|
config.logger.debug "Backtrace:\n" + e.backtrace.join("\n")
|
29
27
|
end
|
30
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
31
28
|
|
32
29
|
private
|
33
30
|
|
@@ -7,7 +7,6 @@ require 'elastic_apm/transaction'
|
|
7
7
|
require 'elastic_apm/span_helpers'
|
8
8
|
|
9
9
|
module ElasticAPM
|
10
|
-
# rubocop:disable Metrics/ClassLength
|
11
10
|
# @api private
|
12
11
|
class Instrumenter
|
13
12
|
TRANSACTION_KEY = :__elastic_instrumenter_transaction_key
|
@@ -61,7 +60,7 @@ module ElasticAPM
|
|
61
60
|
self.current_transaction = nil
|
62
61
|
current_spans.pop until current_spans.empty?
|
63
62
|
|
64
|
-
@subscriber
|
63
|
+
@subscriber&.unregister!
|
65
64
|
end
|
66
65
|
|
67
66
|
def subscriber=(subscriber)
|
@@ -80,7 +79,6 @@ module ElasticAPM
|
|
80
79
|
@current.transaction = transaction
|
81
80
|
end
|
82
81
|
|
83
|
-
# rubocop:disable Metrics/MethodLength
|
84
82
|
def start_transaction(
|
85
83
|
name = nil,
|
86
84
|
type = nil,
|
@@ -112,7 +110,6 @@ module ElasticAPM
|
|
112
110
|
|
113
111
|
self.current_transaction = transaction
|
114
112
|
end
|
115
|
-
# rubocop:enable Metrics/MethodLength
|
116
113
|
|
117
114
|
def end_transaction(result = nil)
|
118
115
|
return nil unless (transaction = current_transaction)
|
@@ -138,8 +135,7 @@ module ElasticAPM
|
|
138
135
|
current_spans.last
|
139
136
|
end
|
140
137
|
|
141
|
-
# rubocop:disable Metrics/
|
142
|
-
# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
|
138
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
143
139
|
# rubocop:disable Metrics/ParameterLists
|
144
140
|
def start_span(
|
145
141
|
name,
|
@@ -183,8 +179,7 @@ module ElasticAPM
|
|
183
179
|
span.start
|
184
180
|
end
|
185
181
|
# rubocop:enable Metrics/ParameterLists
|
186
|
-
# rubocop:enable Metrics/
|
187
|
-
# rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
|
182
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
188
183
|
|
189
184
|
def end_span
|
190
185
|
return unless (span = current_spans.pop)
|
@@ -229,7 +224,6 @@ module ElasticAPM
|
|
229
224
|
rand <= config.transaction_sample_rate
|
230
225
|
end
|
231
226
|
|
232
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
233
227
|
def update_transaction_metrics(transaction)
|
234
228
|
return unless transaction.config.collect_metrics?
|
235
229
|
|
@@ -268,9 +262,7 @@ module ElasticAPM
|
|
268
262
|
tags: span_tags, reset_on_collect: true
|
269
263
|
).inc!
|
270
264
|
end
|
271
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
272
265
|
|
273
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
274
266
|
def update_span_metrics(span)
|
275
267
|
return unless span.transaction.config.breakdown_metrics?
|
276
268
|
|
@@ -292,7 +284,5 @@ module ElasticAPM
|
|
292
284
|
tags: tags, reset_on_collect: true
|
293
285
|
).inc!
|
294
286
|
end
|
295
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
296
287
|
end
|
297
|
-
# rubocop:enable Metrics/ClassLength
|
298
288
|
end
|
@@ -17,8 +17,6 @@ module ElasticAPM
|
|
17
17
|
class Framework < Versioned; end
|
18
18
|
class Language < Versioned; end
|
19
19
|
class Runtime < Versioned; end
|
20
|
-
|
21
|
-
# rubocop:disable Metrics/MethodLength
|
22
20
|
def initialize(config)
|
23
21
|
@config = config
|
24
22
|
|
@@ -33,14 +31,12 @@ module ElasticAPM
|
|
33
31
|
@runtime = lookup_runtime
|
34
32
|
@version = @config.service_version || Util.git_sha
|
35
33
|
end
|
36
|
-
# rubocop:enable Metrics/MethodLength
|
37
34
|
|
38
35
|
attr_reader :name, :environment, :agent, :framework, :language, :runtime,
|
39
36
|
:version
|
40
37
|
|
41
38
|
private
|
42
39
|
|
43
|
-
# rubocop:disable Metrics/MethodLength
|
44
40
|
def lookup_runtime
|
45
41
|
case RUBY_ENGINE
|
46
42
|
when 'ruby'
|
@@ -55,7 +51,6 @@ module ElasticAPM
|
|
55
51
|
)
|
56
52
|
end
|
57
53
|
end
|
58
|
-
# rubocop:enable Metrics/MethodLength
|
59
54
|
end
|
60
55
|
end
|
61
56
|
end
|
@@ -34,7 +34,6 @@ module ElasticAPM
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
# rubocop:disable Metrics/MethodLength
|
38
37
|
def kubernetes
|
39
38
|
@kubernetes =
|
40
39
|
begin
|
@@ -51,7 +50,6 @@ module ElasticAPM
|
|
51
50
|
kubernetes
|
52
51
|
end
|
53
52
|
end
|
54
|
-
# rubocop:enable Metrics/MethodLength
|
55
53
|
|
56
54
|
private
|
57
55
|
|
@@ -70,8 +68,8 @@ module ElasticAPM
|
|
70
68
|
KUBEPODS_REGEX = %r{(?:^/kubepods/[^/]+/pod([^/]+)$)|(?:^/kubepods\.slice/kubepods-[^/]+\.slice/kubepods-[^/]+-pod([^/]+)\.slice$)}.freeze # rubocop:disable Metrics/LineLength
|
71
69
|
SYSTEMD_SCOPE_SUFFIX = '.scope'
|
72
70
|
|
73
|
-
# rubocop:disable Metrics/
|
74
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
71
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
72
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
75
73
|
def read_from_cgroup!
|
76
74
|
return unless File.exist?(cgroup_path)
|
77
75
|
IO.readlines(cgroup_path).each do |line|
|
@@ -113,8 +111,8 @@ module ElasticAPM
|
|
113
111
|
end
|
114
112
|
end
|
115
113
|
end
|
116
|
-
# rubocop:enable Metrics/
|
117
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
114
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
115
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
118
116
|
end
|
119
117
|
end
|
120
118
|
end
|
data/lib/elastic_apm/metrics.rb
CHANGED
@@ -23,8 +23,6 @@ module ElasticAPM
|
|
23
23
|
end
|
24
24
|
|
25
25
|
attr_reader :config, :sets, :callback
|
26
|
-
|
27
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
28
26
|
def start
|
29
27
|
unless config.collect_metrics?
|
30
28
|
debug 'Skipping metrics'
|
@@ -61,7 +59,6 @@ module ElasticAPM
|
|
61
59
|
|
62
60
|
@running = true
|
63
61
|
end
|
64
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
65
62
|
|
66
63
|
def stop
|
67
64
|
return unless running?
|
@@ -68,7 +68,6 @@ module ElasticAPM
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
72
71
|
def read!
|
73
72
|
return if disabled?
|
74
73
|
|
@@ -91,7 +90,6 @@ module ElasticAPM
|
|
91
90
|
|
92
91
|
@previous = current
|
93
92
|
end
|
94
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
95
93
|
|
96
94
|
def calculate_deltas(current, previous)
|
97
95
|
system_cpu_total =
|
@@ -109,7 +107,6 @@ module ElasticAPM
|
|
109
107
|
|
110
108
|
# @api private
|
111
109
|
class Linux
|
112
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
113
110
|
def sample
|
114
111
|
proc_stat = ProcStat.new.read!
|
115
112
|
proc_self_stat = ProcSelfStat.new.read!
|
@@ -126,7 +123,6 @@ module ElasticAPM
|
|
126
123
|
page_size: meminfo.page_size
|
127
124
|
)
|
128
125
|
end
|
129
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
130
126
|
|
131
127
|
# @api private
|
132
128
|
class ProcStat
|
@@ -144,8 +140,6 @@ module ElasticAPM
|
|
144
140
|
guest
|
145
141
|
guest_nice
|
146
142
|
].freeze
|
147
|
-
|
148
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
149
143
|
def read!
|
150
144
|
stat =
|
151
145
|
IO.readlines('/proc/stat')
|
@@ -173,7 +167,6 @@ module ElasticAPM
|
|
173
167
|
|
174
168
|
self
|
175
169
|
end
|
176
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
177
170
|
end
|
178
171
|
|
179
172
|
UTIME_POS = 13
|
@@ -204,8 +197,6 @@ module ElasticAPM
|
|
204
197
|
# @api private
|
205
198
|
class Meminfo
|
206
199
|
attr_reader :total, :available, :page_size
|
207
|
-
|
208
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
209
200
|
# rubocop:disable Metrics/PerceivedComplexity
|
210
201
|
# rubocop:disable Metrics/CyclomaticComplexity
|
211
202
|
def read!
|
@@ -240,7 +231,6 @@ module ElasticAPM
|
|
240
231
|
end
|
241
232
|
# rubocop:enable Metrics/CyclomaticComplexity
|
242
233
|
# rubocop:enable Metrics/PerceivedComplexity
|
243
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
244
234
|
end
|
245
235
|
end
|
246
236
|
end
|
@@ -40,8 +40,11 @@ module ElasticAPM
|
|
40
40
|
metric(Timer, key, tags: tags, **args)
|
41
41
|
end
|
42
42
|
|
43
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
44
43
|
def metric(kls, key, tags: nil, **args)
|
44
|
+
if @config.disable_metrics.any? { |p| p.match? key }
|
45
|
+
return NOOP
|
46
|
+
end
|
47
|
+
|
45
48
|
key = key_with_tags(key, tags)
|
46
49
|
return metrics[key] if metrics[key]
|
47
50
|
|
@@ -64,9 +67,7 @@ module ElasticAPM
|
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
67
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
68
70
|
|
69
|
-
# rubocop:disable Metrics/MethodLength
|
70
71
|
def collect
|
71
72
|
return if disabled?
|
72
73
|
|
@@ -90,7 +91,6 @@ module ElasticAPM
|
|
90
91
|
end.values
|
91
92
|
end
|
92
93
|
end
|
93
|
-
# rubocop:enable Metrics/MethodLength
|
94
94
|
|
95
95
|
private
|
96
96
|
|
@@ -11,7 +11,6 @@ module ElasticAPM
|
|
11
11
|
super
|
12
12
|
end
|
13
13
|
|
14
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
15
14
|
def read!
|
16
15
|
return if disabled?
|
17
16
|
|
@@ -37,8 +36,6 @@ module ElasticAPM
|
|
37
36
|
|
38
37
|
disable!
|
39
38
|
end
|
40
|
-
|
41
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
42
39
|
end
|
43
40
|
end
|
44
41
|
end
|
@@ -10,7 +10,6 @@ module ElasticAPM
|
|
10
10
|
@app = app
|
11
11
|
end
|
12
12
|
|
13
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
14
13
|
def call(env)
|
15
14
|
begin
|
16
15
|
if running? && !path_ignored?(env)
|
@@ -35,7 +34,6 @@ module ElasticAPM
|
|
35
34
|
|
36
35
|
resp
|
37
36
|
end
|
38
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
39
37
|
|
40
38
|
private
|
41
39
|
|
@@ -37,7 +37,8 @@ module ElasticAPM
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def endpoint(env)
|
40
|
-
route_name =
|
40
|
+
route_name =
|
41
|
+
env['api.endpoint']&.routes&.first&.pattern&.origin ||
|
41
42
|
env['REQUEST_PATH']
|
42
43
|
[env['REQUEST_METHOD'], route_name].join(' ')
|
43
44
|
end
|
@@ -22,7 +22,6 @@ module ElasticAPM
|
|
22
22
|
@span_context
|
23
23
|
end
|
24
24
|
|
25
|
-
# rubocop:disable Metrics/MethodLength
|
26
25
|
def set_label(key, val)
|
27
26
|
if elastic_span.is_a?(Transaction)
|
28
27
|
case key.to_s
|
@@ -39,7 +38,6 @@ module ElasticAPM
|
|
39
38
|
elastic_span.context.labels[key] = val
|
40
39
|
end
|
41
40
|
end
|
42
|
-
# rubocop:enable Metrics/MethodLength
|
43
41
|
|
44
42
|
def set_baggage_item(_key, _value)
|
45
43
|
ElasticAPM.agent.config.logger.warn(
|
@@ -63,9 +61,8 @@ module ElasticAPM
|
|
63
61
|
ElasticAPM.report_message message
|
64
62
|
end
|
65
63
|
end
|
66
|
-
# rubocop:enable Lint/UnusedMethodArgument
|
67
64
|
|
68
|
-
# rubocop:
|
65
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
69
66
|
def finish(clock_end: Util.monotonic_micros, end_time: nil)
|
70
67
|
return unless (agent = ElasticAPM.agent)
|
71
68
|
|
@@ -86,7 +83,6 @@ module ElasticAPM
|
|
86
83
|
|
87
84
|
agent.enqueue elastic_span
|
88
85
|
end
|
89
|
-
# rubocop:enable Metrics/MethodLength
|
90
86
|
|
91
87
|
private
|
92
88
|
|
@@ -179,8 +175,6 @@ module ElasticAPM
|
|
179
175
|
@scope_stack.last
|
180
176
|
end
|
181
177
|
end
|
182
|
-
|
183
|
-
# rubocop:disable Metrics/ClassLength
|
184
178
|
# A custom tracer to use the OpenTracing API with ElasticAPM
|
185
179
|
class Tracer
|
186
180
|
def initialize
|
@@ -193,7 +187,7 @@ module ElasticAPM
|
|
193
187
|
scope_manager.active&.span
|
194
188
|
end
|
195
189
|
|
196
|
-
# rubocop:disable Metrics/
|
190
|
+
# rubocop:disable Metrics/ParameterLists
|
197
191
|
def start_active_span(
|
198
192
|
operation_name,
|
199
193
|
child_of: nil,
|
@@ -224,10 +218,9 @@ module ElasticAPM
|
|
224
218
|
|
225
219
|
scope
|
226
220
|
end
|
227
|
-
# rubocop:enable Metrics/
|
221
|
+
# rubocop:enable Metrics/ParameterLists
|
228
222
|
|
229
|
-
# rubocop:disable Metrics/
|
230
|
-
# rubocop:disable Metrics/AbcSize
|
223
|
+
# rubocop:disable Metrics/ParameterLists
|
231
224
|
def start_span(
|
232
225
|
operation_name,
|
233
226
|
child_of: nil,
|
@@ -245,7 +238,6 @@ module ElasticAPM
|
|
245
238
|
|
246
239
|
if span_context
|
247
240
|
trace_context =
|
248
|
-
span_context &&
|
249
241
|
span_context.respond_to?(:trace_context) &&
|
250
242
|
span_context.trace_context
|
251
243
|
end
|
@@ -279,8 +271,8 @@ module ElasticAPM
|
|
279
271
|
|
280
272
|
Span.new(elastic_span, span_context)
|
281
273
|
end
|
282
|
-
|
283
|
-
# rubocop:enable Metrics/
|
274
|
+
|
275
|
+
# rubocop:enable Metrics/ParameterLists
|
284
276
|
|
285
277
|
def inject(span_context, format, carrier)
|
286
278
|
case format
|
@@ -341,6 +333,5 @@ module ElasticAPM
|
|
341
333
|
@scope_manager.active&.span&.context
|
342
334
|
end
|
343
335
|
end
|
344
|
-
# rubocop:enable Metrics/ClassLength
|
345
336
|
end
|
346
337
|
end
|