elastic-apm 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of elastic-apm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -6
- data/Gemfile +1 -0
- data/bench/benchmark.rb +6 -2
- data/bench/report.rb +12 -9
- data/docs/api.asciidoc +2 -0
- data/docs/configuration.asciidoc +26 -0
- data/docs/index.asciidoc +2 -1
- data/docs/troubleshooting.asciidoc +28 -0
- data/lib/elastic_apm/agent.rb +22 -10
- data/lib/elastic_apm/config.rb +15 -3
- data/lib/elastic_apm/context.rb +3 -3
- data/lib/elastic_apm/filters/secrets_filter.rb +2 -2
- data/lib/elastic_apm/instrumenter.rb +18 -13
- data/lib/elastic_apm/middleware.rb +3 -2
- data/lib/elastic_apm/normalizers/active_record.rb +1 -1
- data/lib/elastic_apm/serializers/errors.rb +1 -1
- data/lib/elastic_apm/serializers/transactions.rb +2 -2
- data/lib/elastic_apm/service_info.rb +2 -2
- data/lib/elastic_apm/spies/rake.rb +46 -0
- data/lib/elastic_apm/transaction.rb +1 -0
- data/lib/elastic_apm/util/inflector.rb +1 -1
- data/lib/elastic_apm/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cf86b8835f2524fc990aad795d4f2f4fc8a4ed3c3742436649f5ceb44b96c82
|
4
|
+
data.tar.gz: c0a0a828cdd4f4eb0306131bb5b12d423e519bd57c0f19420928299505c08f03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b404e23f7056ece4ee3603a91e3d1f95894fb0ed62a32e7bbccf8a83ed462e17afc99073fa36ef317e430a13dce343396e1059a28b1d03c4497070f992e4133f
|
7
|
+
data.tar.gz: 667f2932cf52bd2eaeeb4dbdd7c37fb183ab9e78f49eafa7dfa004f16b3361dd9d71183648ab40aee996d9e4c04d8f789298acc872de2f532173ab579eb4882e
|
data/CHANGELOG.md
CHANGED
@@ -4,20 +4,28 @@ 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
|
-
##
|
7
|
+
## 1.0.2 (2018-09-07)
|
8
8
|
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Rake task instrumentation ([#192](https://github.com/elastic/apm-agent-ruby/pull/192))
|
12
|
+
- `default_tags` option ([#183](https://github.com/elastic/apm-agent-ruby/pull/183))
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
|
16
|
+
- Fallback from missing JRUBY_VERSION ([#180](https://github.com/elastic/apm-agent-ruby/pull/180))
|
9
17
|
|
10
18
|
## 1.0.1 (2018-07-30)
|
11
19
|
|
12
20
|
### Fixed
|
13
21
|
|
14
|
-
- Fixed internal LRU cache to be threadsafe ([#178](https://github.com/elastic/apm-agent-ruby/
|
22
|
+
- Fixed internal LRU cache to be threadsafe ([#178](https://github.com/elastic/apm-agent-ruby/pull/178))
|
15
23
|
|
16
24
|
## 1.0.0 (2018-06-29)
|
17
25
|
|
18
26
|
### Added
|
19
27
|
|
20
|
-
- Added config.disable_send ([#156](https://github.com/elastic/apm-agent-ruby/
|
28
|
+
- Added config.disable_send ([#156](https://github.com/elastic/apm-agent-ruby/pull/156))
|
21
29
|
|
22
30
|
### Changed
|
23
31
|
|
@@ -25,14 +33,14 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
25
33
|
|
26
34
|
### Fixed
|
27
35
|
|
28
|
-
- Fixed some Elasticsearch spans not validating JSON Schema ([#157](https://github.com/elastic/apm-agent-ruby/
|
36
|
+
- Fixed some Elasticsearch spans not validating JSON Schema ([#157](https://github.com/elastic/apm-agent-ruby/pull/157))
|
29
37
|
|
30
38
|
## 0.8.0 (2018-06-13)
|
31
39
|
|
32
40
|
### Added
|
33
41
|
|
34
|
-
- Added an option to disable metrics collection ([#145](https://github.com/elastic/apm-agent-ruby/
|
35
|
-
- Filters can cancel the entire payload by returning `nil` ([#148](https://github.com/elastic/apm-agent-ruby/
|
42
|
+
- Added an option to disable metrics collection ([#145](https://github.com/elastic/apm-agent-ruby/pull/145))
|
43
|
+
- Filters can cancel the entire payload by returning `nil` ([#148](https://github.com/elastic/apm-agent-ruby/pull/148))
|
36
44
|
- Added `ENV` version of the logging options ([#146](https://github.com/elastic/apm-agent-ruby/pull/146))
|
37
45
|
- Added `config.ignore_url_patterns` ([#151](https://github.com/elastic/apm-agent-ruby/pull/151))
|
38
46
|
|
data/Gemfile
CHANGED
data/bench/benchmark.rb
CHANGED
@@ -42,7 +42,11 @@ def do_bench(transaction_count: 10, **config)
|
|
42
42
|
bench = Benchmark.benchmark(CAPTION, 7, FORMAT, 'avg:') do |x|
|
43
43
|
benchmarks =
|
44
44
|
with_app(config) do |app|
|
45
|
-
|
45
|
+
# warm-up
|
46
|
+
puts "1 run of warm-up"
|
47
|
+
perform(app, count: transaction_count)
|
48
|
+
|
49
|
+
5.times.map do |i|
|
46
50
|
x.report("run[#{i}]") { perform(app, count: transaction_count) }
|
47
51
|
end
|
48
52
|
end
|
@@ -51,7 +55,7 @@ def do_bench(transaction_count: 10, **config)
|
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
54
|
-
transaction_count = Integer(ARGV.shift ||
|
58
|
+
transaction_count = Integer(ARGV.shift || 100_000)
|
55
59
|
|
56
60
|
banner 'Default settings'
|
57
61
|
do_bench transaction_count: transaction_count
|
data/bench/report.rb
CHANGED
@@ -13,8 +13,10 @@ if ELASTICSEARCH_URL == ''
|
|
13
13
|
puts 'ELASTICSEARCH_URL missing, exiting ...'
|
14
14
|
exit 1
|
15
15
|
else
|
16
|
-
#
|
17
|
-
# puts ELASTICSEARCH_URL.gsub(/:[^\/]+(.*)@/)
|
16
|
+
# DEBUG
|
17
|
+
# puts ELASTICSEARCH_URL.gsub(/:[^\/]+(.*)@/) do |m|
|
18
|
+
# ":#{Array.new(m.length - 2).map { '*' }.join}@"
|
19
|
+
# end
|
18
20
|
end
|
19
21
|
|
20
22
|
CONN = Faraday.new(url: ELASTICSEARCH_URL) do |f|
|
@@ -35,30 +37,31 @@ titles = input.grep(/^===/).map { |t| t.gsub(/^=== /, '') }
|
|
35
37
|
counts = input.grep(/^Count: /).map { |a| a.gsub(/^Count: /, '').to_i }
|
36
38
|
averages = input.grep(/^avg/).map { |a| a.match(/\((.+)\)/)[1].to_f }
|
37
39
|
|
38
|
-
git_sha,
|
39
|
-
git_date
|
40
|
-
git_branch = `git branch | grep '\*' | awk '{print $2}'`
|
40
|
+
git_sha, git_msg = `git log -n 1 --pretty="format:%H|||%s"`.split('|||')
|
41
|
+
git_date = `git log -n 1 --pretty="format:%ai"`
|
41
42
|
platform = Gem::Platform.local
|
42
43
|
|
43
44
|
payloads = titles.zip(averages, counts).map do |(title, avg, count)|
|
45
|
+
return nil unless avg
|
46
|
+
|
44
47
|
{
|
45
48
|
title: title,
|
46
49
|
avg: avg,
|
47
50
|
transaction_count: count,
|
48
51
|
executed_at: Time.new.iso8601,
|
49
52
|
'git.commit' => git_sha,
|
50
|
-
'git.date' => Time.parse(git_date).iso8601,
|
53
|
+
'git.date' => String(git_date).strip != '' && Time.parse(git_date).iso8601,
|
51
54
|
'git.subject' => git_msg,
|
52
|
-
'git.branch' => git_branch,
|
53
55
|
hostname: `hostname`.chomp,
|
54
56
|
engine: RUBY_ENGINE,
|
55
57
|
arch: platform.cpu,
|
56
58
|
os: platform.os,
|
57
|
-
ruby_version: RUBY_VERSION
|
59
|
+
ruby_version: "#{RUBY_ENGINE == 'jruby' ? 'j' : ''}#{RUBY_VERSION}"
|
58
60
|
}
|
59
|
-
end
|
61
|
+
end.compact
|
60
62
|
|
61
63
|
puts '=== Reporting to ES'
|
64
|
+
puts payloads.inspect
|
62
65
|
|
63
66
|
payloads.each do |payload|
|
64
67
|
result = CONN.post('/benchmark-ruby/_doc') do |req|
|
data/docs/api.asciidoc
CHANGED
@@ -208,6 +208,8 @@ Arguments:
|
|
208
208
|
|
209
209
|
Returns the set `value`.
|
210
210
|
|
211
|
+
WARNING: Be aware that tags are indexed in Elasticsearch. Using too many unique keys will result in *https://www.elastic.co/blog/found-crash-elasticsearch#mapping-explosion[Mapping explosion]*.
|
212
|
+
|
211
213
|
[float]
|
212
214
|
[[api-agent-set-custom-context]]
|
213
215
|
==== `ElasticAPM.set_custom_context`
|
data/docs/configuration.asciidoc
CHANGED
@@ -389,6 +389,32 @@ Use this option to disable any of these.
|
|
389
389
|
|
390
390
|
Get an array of enabled spies with `ElasticAPM.agent.config.enabled_spies`.
|
391
391
|
|
392
|
+
[float]
|
393
|
+
[[config-instrumented-rake-tasks]]
|
394
|
+
==== `instrumented_rake_tasks`
|
395
|
+
|
396
|
+
[options="header"]
|
397
|
+
|============
|
398
|
+
| Environment | `Config` key | Default | Example
|
399
|
+
| `ELASTIC_APM_INSTRUMENTED_RAKE_TASKS` | `instrumented_rake_tasks` | `[]` | `['my_task']`
|
400
|
+
|============
|
401
|
+
|
402
|
+
Elastic APM can instrument your Rake tasks but given that they are used for a multitude of sometimes very different and not always relevant things, this is opt in.
|
403
|
+
|
404
|
+
[float]
|
405
|
+
[[config-default-tags]]
|
406
|
+
==== `default_tags`
|
407
|
+
|
408
|
+
[options="header"]
|
409
|
+
|============
|
410
|
+
| Environment | `Config` key | Default | Example
|
411
|
+
| `ELASTIC_APM_DEFAULT_TAGS` | `default_tags` | `{}` | `region=us1`
|
412
|
+
|============
|
413
|
+
|
414
|
+
Add default tags to add to every transaction.
|
415
|
+
|
416
|
+
WARNING: Be aware that tags are indexed in Elasticsearch. Using too many unique keys will result in *https://www.elastic.co/blog/found-crash-elasticsearch#mapping-explosion[Mapping explosion]*.
|
417
|
+
|
392
418
|
[float]
|
393
419
|
[[config-custom-key-filters]]
|
394
420
|
==== `custom_key_filters`
|
data/docs/index.asciidoc
CHANGED
@@ -5,7 +5,7 @@ ifdef::env-github[]
|
|
5
5
|
NOTE: For the best reading experience, please view this documentation at https://www.elastic.co/guide/en/apm/agent/ruby[elastic.co]
|
6
6
|
endif::[]
|
7
7
|
|
8
|
-
= APM Ruby Agent Reference
|
8
|
+
= APM Ruby Agent Reference
|
9
9
|
|
10
10
|
[[introduction]]
|
11
11
|
== Introduction
|
@@ -31,6 +31,7 @@ include::./configuration.asciidoc[]
|
|
31
31
|
== Advanced Topics
|
32
32
|
include::./context.asciidoc[]
|
33
33
|
include::./custom-instrumentation.asciidoc[]
|
34
|
+
include::./troubleshooting.asciidoc[]
|
34
35
|
|
35
36
|
include::./api.asciidoc[]
|
36
37
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
[[debugging]]
|
2
|
+
=== Debugging APM
|
3
|
+
|
4
|
+
The agent not working for you? There are a few settings that might help:
|
5
|
+
|
6
|
+
[float]
|
7
|
+
[[debugging-debug-transactions]]
|
8
|
+
==== `debug_transactions`
|
9
|
+
|
10
|
+
[options="header"]
|
11
|
+
|============
|
12
|
+
| Environment | `Config` key | Default
|
13
|
+
| `ELASTIC_APM_DEBUG_TRANSACTIONS` | `debug_transactions` | `false`
|
14
|
+
|============
|
15
|
+
|
16
|
+
When on, Elastic APM will log a summary of each transaction when submitted.
|
17
|
+
|
18
|
+
[float]
|
19
|
+
[[debugging-debug-http]]
|
20
|
+
==== `debug_http`
|
21
|
+
|
22
|
+
[options="header"]
|
23
|
+
|============
|
24
|
+
| Environment | `Config` key | Default
|
25
|
+
| `ELASTIC_APM_DEBUG_HTTP` | `debug_http` | `false`
|
26
|
+
|============
|
27
|
+
|
28
|
+
When on, Elastic APM will log debug information from all the requests it makes to APM Server.
|
data/lib/elastic_apm/agent.rb
CHANGED
@@ -132,12 +132,24 @@ module ElasticAPM
|
|
132
132
|
instrumenter.current_transaction
|
133
133
|
end
|
134
134
|
|
135
|
-
def transaction(
|
136
|
-
instrumenter.transaction(
|
135
|
+
def transaction(name = nil, type = nil, context: nil, sampled: nil, &block)
|
136
|
+
instrumenter.transaction(
|
137
|
+
name,
|
138
|
+
type,
|
139
|
+
context: context,
|
140
|
+
sampled: sampled,
|
141
|
+
&block
|
142
|
+
)
|
137
143
|
end
|
138
144
|
|
139
|
-
def span(
|
140
|
-
instrumenter.span(
|
145
|
+
def span(name, type = nil, backtrace: nil, context: nil, &block)
|
146
|
+
instrumenter.span(
|
147
|
+
name,
|
148
|
+
type,
|
149
|
+
backtrace: backtrace,
|
150
|
+
context: context,
|
151
|
+
&block
|
152
|
+
)
|
141
153
|
end
|
142
154
|
|
143
155
|
def build_context(rack_env)
|
@@ -167,16 +179,16 @@ module ElasticAPM
|
|
167
179
|
|
168
180
|
# context
|
169
181
|
|
170
|
-
def set_tag(
|
171
|
-
instrumenter.set_tag(
|
182
|
+
def set_tag(key, value)
|
183
|
+
instrumenter.set_tag(key, value)
|
172
184
|
end
|
173
185
|
|
174
|
-
def set_custom_context(
|
175
|
-
instrumenter.set_custom_context(
|
186
|
+
def set_custom_context(context)
|
187
|
+
instrumenter.set_custom_context(context)
|
176
188
|
end
|
177
189
|
|
178
|
-
def set_user(
|
179
|
-
instrumenter.set_user(
|
190
|
+
def set_user(user)
|
191
|
+
instrumenter.set_user(user)
|
180
192
|
end
|
181
193
|
|
182
194
|
def add_filter(key, callback)
|
data/lib/elastic_apm/config.rb
CHANGED
@@ -42,6 +42,9 @@ module ElasticAPM
|
|
42
42
|
span_frames_min_duration: 5,
|
43
43
|
|
44
44
|
disabled_spies: %w[json],
|
45
|
+
instrumented_rake_tasks: [],
|
46
|
+
|
47
|
+
default_tags: {},
|
45
48
|
|
46
49
|
current_user_id_method: :id,
|
47
50
|
current_user_email_method: :email,
|
@@ -95,7 +98,11 @@ module ElasticAPM
|
|
95
98
|
'ELASTIC_APM_TRANSACTION_MAX_SPANS' => [:int, 'transaction_max_spans'],
|
96
99
|
|
97
100
|
'ELASTIC_APM_DISABLE_SEND' => [:bool, 'disable_send'],
|
98
|
-
'ELASTIC_APM_DISABLED_SPIES' => [:list, 'disabled_spies']
|
101
|
+
'ELASTIC_APM_DISABLED_SPIES' => [:list, 'disabled_spies'],
|
102
|
+
'ELASTIC_APM_INSTRUMENTED_RAKE_TASKS' =>
|
103
|
+
[:list, 'instrumented_rake_tasks'],
|
104
|
+
|
105
|
+
'ELASTIC_APM_DEFAULT_TAGS' => [:dict, 'default_tags']
|
99
106
|
}.freeze
|
100
107
|
|
101
108
|
def initialize(options = {})
|
@@ -153,6 +160,7 @@ module ElasticAPM
|
|
153
160
|
attr_accessor :span_frames_min_duration
|
154
161
|
|
155
162
|
attr_accessor :disabled_spies
|
163
|
+
attr_accessor :instrumented_rake_tasks
|
156
164
|
|
157
165
|
attr_accessor :view_paths
|
158
166
|
attr_accessor :root_path
|
@@ -162,12 +170,14 @@ module ElasticAPM
|
|
162
170
|
attr_accessor :current_user_email_method
|
163
171
|
attr_accessor :current_user_username_method
|
164
172
|
|
173
|
+
attr_accessor :default_tags
|
174
|
+
|
165
175
|
attr_reader :custom_key_filters
|
166
176
|
attr_reader :ignore_url_patterns
|
167
177
|
|
168
178
|
alias :disable_environment_warning? :disable_environment_warning
|
169
|
-
alias :verify_server_cert? :verify_server_cert
|
170
179
|
alias :disable_send? :disable_send
|
180
|
+
alias :verify_server_cert? :verify_server_cert
|
171
181
|
|
172
182
|
def app=(app)
|
173
183
|
case app_type?(app)
|
@@ -182,7 +192,7 @@ module ElasticAPM
|
|
182
192
|
end
|
183
193
|
|
184
194
|
def app_type?(app)
|
185
|
-
if defined?(::
|
195
|
+
if defined?(Rails::Application) && app.is_a?(Rails::Application)
|
186
196
|
return :rails
|
187
197
|
end
|
188
198
|
|
@@ -219,6 +229,7 @@ module ElasticAPM
|
|
219
229
|
sidekiq
|
220
230
|
sinatra
|
221
231
|
tilt
|
232
|
+
rake
|
222
233
|
]
|
223
234
|
end
|
224
235
|
# rubocop:enable Metrics/MethodLength
|
@@ -252,6 +263,7 @@ module ElasticAPM
|
|
252
263
|
when :float then value.to_f
|
253
264
|
when :bool then !%w[0 false].include?(value.strip.downcase)
|
254
265
|
when :list then value.split(/[ ,]/)
|
266
|
+
when :dict then Hash[value.split('&').map { |kv| kv.split('=') }]
|
255
267
|
else value
|
256
268
|
end
|
257
269
|
|
data/lib/elastic_apm/context.rb
CHANGED
@@ -48,11 +48,11 @@ module ElasticAPM
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def filter_key?(key)
|
51
|
-
@key_filters.any? { |regex| key
|
51
|
+
@key_filters.any? { |regex| key.match regex }
|
52
52
|
end
|
53
53
|
|
54
54
|
def filter_value?(value)
|
55
|
-
VALUE_FILTERS.any? { |regex| value
|
55
|
+
VALUE_FILTERS.any? { |regex| value.match regex }
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -55,9 +55,9 @@ module ElasticAPM
|
|
55
55
|
@transaction_info.current = transaction
|
56
56
|
end
|
57
57
|
|
58
|
-
# rubocop:disable Metrics/MethodLength
|
59
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
60
|
-
def transaction(
|
58
|
+
# rubocop:disable Metrics/MethodLength
|
59
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
60
|
+
def transaction(name = nil, type = nil, context: nil, sampled: nil)
|
61
61
|
unless config.instrument
|
62
62
|
yield if block_given?
|
63
63
|
return
|
@@ -68,13 +68,10 @@ module ElasticAPM
|
|
68
68
|
return transaction
|
69
69
|
end
|
70
70
|
|
71
|
-
if
|
72
|
-
args.last[:sampled] = random_sample?
|
73
|
-
else
|
74
|
-
args.push(sampled: random_sample?)
|
75
|
-
end
|
71
|
+
sampled = random_sample? if sampled.nil?
|
76
72
|
|
77
|
-
transaction =
|
73
|
+
transaction =
|
74
|
+
Transaction.new self, name, type, context: context, sampled: sampled
|
78
75
|
|
79
76
|
self.current_transaction = transaction
|
80
77
|
return transaction unless block_given?
|
@@ -88,21 +85,29 @@ module ElasticAPM
|
|
88
85
|
|
89
86
|
transaction
|
90
87
|
end
|
91
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
92
|
-
# rubocop:enable Metrics/MethodLength
|
88
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
89
|
+
# rubocop:enable Metrics/MethodLength
|
93
90
|
|
94
91
|
def random_sample?
|
95
92
|
rand <= config.transaction_sample_rate
|
96
93
|
end
|
97
94
|
|
98
|
-
|
95
|
+
# rubocop:disable Metrics/MethodLength
|
96
|
+
def span(name, type = nil, backtrace: nil, context: nil, &block)
|
99
97
|
unless current_transaction
|
100
98
|
return yield if block_given?
|
101
99
|
return
|
102
100
|
end
|
103
101
|
|
104
|
-
current_transaction.span(
|
102
|
+
current_transaction.span(
|
103
|
+
name,
|
104
|
+
type,
|
105
|
+
backtrace: backtrace,
|
106
|
+
context: context,
|
107
|
+
&block
|
108
|
+
)
|
105
109
|
end
|
110
|
+
# rubocop:enable Metrics/MethodLength
|
106
111
|
|
107
112
|
def set_tag(key, value)
|
108
113
|
return unless current_transaction
|
@@ -16,7 +16,8 @@ module ElasticAPM
|
|
16
16
|
|
17
17
|
resp = @app.call env
|
18
18
|
|
19
|
-
|
19
|
+
status, headers, body = resp
|
20
|
+
submit_transaction(transaction, status, headers, body) if transaction
|
20
21
|
rescue InternalError
|
21
22
|
raise # Don't report ElasticAPM errors
|
22
23
|
rescue ::Exception => e
|
@@ -38,7 +39,7 @@ module ElasticAPM
|
|
38
39
|
|
39
40
|
def path_ignored?(env)
|
40
41
|
config.ignore_url_patterns.any? do |r|
|
41
|
-
env['PATH_INFO']
|
42
|
+
env['PATH_INFO'].match r
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
@@ -13,7 +13,7 @@ module ElasticAPM
|
|
13
13
|
result: transaction.result.to_s,
|
14
14
|
duration: ms(transaction.duration),
|
15
15
|
timestamp: micros_to_time(transaction.timestamp).utc.iso8601(3),
|
16
|
-
spans: transaction.spans.map(
|
16
|
+
spans: transaction.spans.map { |s| build_span(s) },
|
17
17
|
sampled: transaction.sampled,
|
18
18
|
context: transaction.context.to_h
|
19
19
|
}
|
@@ -27,7 +27,7 @@ module ElasticAPM
|
|
27
27
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
28
28
|
|
29
29
|
def build_all(transactions)
|
30
|
-
{ transactions: Array(transactions).map(
|
30
|
+
{ transactions: Array(transactions).map { |t| build(t) } }
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
@@ -45,9 +45,9 @@ module ElasticAPM
|
|
45
45
|
def runtime
|
46
46
|
case RUBY_ENGINE
|
47
47
|
when 'ruby'
|
48
|
-
{ name: RUBY_ENGINE, version: RUBY_VERSION }
|
48
|
+
{ name: RUBY_ENGINE, version: RUBY_VERSION || RUBY_ENGINE_VERSION }
|
49
49
|
when 'jruby'
|
50
|
-
{ name: RUBY_ENGINE, version:
|
50
|
+
{ name: RUBY_ENGINE, version: JRUBY_VERSION || RUBY_ENGINE_VERSION }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElasticAPM
|
4
|
+
# @api private
|
5
|
+
module Spies
|
6
|
+
# @api private
|
7
|
+
class RakeSpy
|
8
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
9
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
10
|
+
def install
|
11
|
+
::Rake::Task.class_eval do
|
12
|
+
alias execute_without_apm execute
|
13
|
+
|
14
|
+
def execute(*args)
|
15
|
+
agent = ElasticAPM.start
|
16
|
+
|
17
|
+
unless agent && agent.config.instrumented_rake_tasks.include?(name)
|
18
|
+
return execute_without_apm(*args)
|
19
|
+
end
|
20
|
+
|
21
|
+
transaction = ElasticAPM.transaction("Rake::Task[#{name}]", 'Rake')
|
22
|
+
|
23
|
+
begin
|
24
|
+
result = execute_without_apm(*args)
|
25
|
+
|
26
|
+
transaction.submit('success') if transaction
|
27
|
+
rescue StandardError => e
|
28
|
+
transaction.submit(:error) if transaction
|
29
|
+
ElasticAPM.report(e)
|
30
|
+
|
31
|
+
raise
|
32
|
+
ensure
|
33
|
+
transaction.release if transaction
|
34
|
+
ElasticAPM.stop
|
35
|
+
end
|
36
|
+
|
37
|
+
result
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
42
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
43
|
+
end
|
44
|
+
register 'Rake::Task', 'rake', RakeSpy.new
|
45
|
+
end
|
46
|
+
end
|
@@ -85,7 +85,7 @@ module ElasticAPM
|
|
85
85
|
raise if e.name && !(camel_cased_word.to_s.split("::").include?(e.name.to_s) ||
|
86
86
|
e.name.to_s == camel_cased_word.to_s)
|
87
87
|
rescue ArgumentError => e
|
88
|
-
raise unless /not missing constant #{const_regexp(camel_cased_word)}!$/.match
|
88
|
+
raise unless /not missing constant #{const_regexp(camel_cased_word)}!$/.match(e.message)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
data/lib/elastic_apm/version.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikkel Malmberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07
|
11
|
+
date: 2018-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- docs/getting-started-rack.asciidoc
|
61
61
|
- docs/getting-started-rails.asciidoc
|
62
62
|
- docs/index.asciidoc
|
63
|
+
- docs/troubleshooting.asciidoc
|
63
64
|
- elastic-apm.gemspec
|
64
65
|
- lib/elastic-apm.rb
|
65
66
|
- lib/elastic_apm.rb
|
@@ -106,6 +107,7 @@ files:
|
|
106
107
|
- lib/elastic_apm/spies/json.rb
|
107
108
|
- lib/elastic_apm/spies/mongo.rb
|
108
109
|
- lib/elastic_apm/spies/net_http.rb
|
110
|
+
- lib/elastic_apm/spies/rake.rb
|
109
111
|
- lib/elastic_apm/spies/redis.rb
|
110
112
|
- lib/elastic_apm/spies/sequel.rb
|
111
113
|
- lib/elastic_apm/spies/sidekiq.rb
|