appsignal 3.0.20 → 3.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -0
- data/appsignal.gemspec +2 -1
- data/ext/agent.yml +25 -25
- data/lib/appsignal/cli/diagnose.rb +2 -1
- data/lib/appsignal/config.rb +40 -26
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +7 -18
- data/lib/appsignal/hooks/active_job.rb +4 -2
- data/lib/appsignal/utils/query_params_sanitizer.rb +1 -1
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +0 -15
- data/spec/lib/appsignal/cli/diagnose_spec.rb +9 -6
- data/spec/lib/appsignal/config_spec.rb +81 -72
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +21 -47
- data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +5 -1
- data/spec/lib/appsignal/integrations/padrino_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +11 -3
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +7 -7
- data/spec/lib/appsignal_spec.rb +58 -36
- data/spec/support/helpers/transaction_helpers.rb +10 -0
- metadata +8 -9
- data/spec/support/mocks/mock_extension.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc3f95c67f5a07b90ad69c93d22966628bf93c8e5fb24c0920ee2b9faf0e9107
|
4
|
+
data.tar.gz: 9b2ed342eb75461e8c19788789ca254dadbfc6d97ec1eb226438d3c4b91c25c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15344ae58ab31b923ef5687c7ad2feeb5ed740131f406a3ec523343ac7cb3caf4626aa760554fb1cdc1d47f6a032da1c46f68bd01289579bb8e0855332f9d664
|
7
|
+
data.tar.gz: 7c7a6df9b85a50d3f56853a5ba3f7412a09a68312db3703a7c4937afa440157fc04a4b6931184f1039d5fbb22b37c35e346f88a2f917ee032cb7aea32de2868c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,49 @@
|
|
1
1
|
# AppSignal for Ruby gem Changelog
|
2
2
|
|
3
|
+
## 3.0.24
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
|
7
|
+
- [964861f7](https://github.com/appsignal/appsignal-ruby/commit/964861f76ea7ff71f01497f116def14190bcd404) patch - Bump agent to v-f57e6cb
|
8
|
+
|
9
|
+
- Enable process metrics on Heroku and Dokku
|
10
|
+
|
11
|
+
## 3.0.23
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- [d73905d3](https://github.com/appsignal/appsignal-ruby/commit/d73905d3b28404638a8aa1e8de3909eff0b8cfb6) patch - Fix sanitized values wrapped in Arrays. When a value like `[{ "foo" => "bar" }]` was sanitized it would be stored as `{ "foo" => "?" }`, omitting the parent value's Array square brackets. Now values will appear with the same structure as they were originally sanitized. This only applies to certain integrations like MongoDB, moped and ElasticSearch.
|
16
|
+
- [096d3cdf](https://github.com/appsignal/appsignal-ruby/commit/096d3cdfd8f452f13b2dbf7de6b763c8a96973b3) patch - Fix the ActiveJob `default_queue_name` config option issue being reset to "default". When ActiveJob `default_queue_name` was set in a Rails initializer it would reset on load to `default`. Now the `default_queue_name` can be set in an initializer as well.
|
17
|
+
|
18
|
+
## 3.0.22
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
|
22
|
+
- [9762e79d](https://github.com/appsignal/appsignal-ruby/commit/9762e79d4545e50c8f3540deff825b10d77e59a5) patch - Bump agent to v-bbc830a
|
23
|
+
|
24
|
+
- Support batched statsd messages
|
25
|
+
- Set start times for spans with traceparents
|
26
|
+
- Check duration in transactions for negative and too high value
|
27
|
+
|
28
|
+
## 3.0.21
|
29
|
+
|
30
|
+
### Changed
|
31
|
+
|
32
|
+
- [548dd6f4](https://github.com/appsignal/appsignal-ruby/commit/548dd6f4c61ae3be24995a200dc3e5bea1a5f58c) patch - Add config override source. Track final decisions made by the Ruby gem in the configuration in the `override` config source. This will help us track new config options which are being set by their deprecated predecessors in the diagnose report.
|
33
|
+
|
34
|
+
### Removed
|
35
|
+
|
36
|
+
- [3f503ade](https://github.com/appsignal/appsignal-ruby/commit/3f503ade83f22f4b0d86d76ea00e5f4dd3c56b6f) patch - Remove internal `Appsignal.extensions` system. It was unused.
|
37
|
+
|
38
|
+
## 3.0.21.alpha.1
|
39
|
+
|
40
|
+
### Changed
|
41
|
+
|
42
|
+
- [f19d9dcc](https://github.com/appsignal/appsignal-ruby/commit/f19d9dcc1c00103f5dc92951481becf4d4ade39e) patch - The MongoDB query sanitization now shows all the attributes in the query at all levels.
|
43
|
+
Only the actual values are filtered with a `?` character. Less MongoDB queries are now marked
|
44
|
+
as N+1 queries when they weren't the exact same query. This increases the number of unique events
|
45
|
+
AppSignal tracks for MongoDB queries.
|
46
|
+
|
3
47
|
## 3.0.20
|
4
48
|
|
5
49
|
### Added
|
@@ -182,6 +226,10 @@ Please read our [upgrade from version 2 to 3 guide][upgrade3] before upgrading.
|
|
182
226
|
- Add Sidekiq error handler. Report more Sidekiq errors that happen around job
|
183
227
|
execution. PR #699
|
184
228
|
|
229
|
+
## 2.11.10
|
230
|
+
- Backport extension fallbacks on extension installation failure, that caused
|
231
|
+
NoMethodErrors. PR #736
|
232
|
+
|
185
233
|
## 2.11.9
|
186
234
|
- Fix and simplify Ruby method delegation for object method instrumentation in
|
187
235
|
the different Ruby versions. PR #706
|
data/appsignal.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |gem| # rubocop:disable Metrics/BlockLength
|
|
25
25
|
gem.extensions = %w[ext/extconf.rb]
|
26
26
|
|
27
27
|
gem.metadata = {
|
28
|
+
"rubygems_mfa_required" => "true",
|
28
29
|
"bug_tracker_uri" => "https://github.com/appsignal/appsignal-ruby/issues",
|
29
30
|
"changelog_uri" =>
|
30
31
|
"https://github.com/appsignal/appsignal-ruby/blob/main/CHANGELOG.md",
|
@@ -35,7 +36,7 @@ Gem::Specification.new do |gem| # rubocop:disable Metrics/BlockLength
|
|
35
36
|
|
36
37
|
gem.add_dependency "rack"
|
37
38
|
|
38
|
-
gem.add_development_dependency "rake", "
|
39
|
+
gem.add_development_dependency "rake", ">= 12"
|
39
40
|
gem.add_development_dependency "rspec", "~> 3.8"
|
40
41
|
gem.add_development_dependency "timecop"
|
41
42
|
gem.add_development_dependency "webmock"
|
data/ext/agent.yml
CHANGED
@@ -3,92 +3,92 @@
|
|
3
3
|
# appsignal-agent repository.
|
4
4
|
# Modifications to this file will be overwritten with the next agent release.
|
5
5
|
---
|
6
|
-
version:
|
6
|
+
version: f57e6cb
|
7
7
|
mirrors:
|
8
8
|
- https://appsignal-agent-releases.global.ssl.fastly.net
|
9
9
|
- https://d135dj0rjqvssy.cloudfront.net
|
10
10
|
triples:
|
11
11
|
x86_64-darwin:
|
12
12
|
static:
|
13
|
-
checksum:
|
13
|
+
checksum: dd1ae8d7897edf3112741381226e3622e91553dede6eeae48ca07aae84ac050d
|
14
14
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
15
15
|
dynamic:
|
16
|
-
checksum:
|
16
|
+
checksum: a523a85f76bdb37ffcacbf14279c3c7fed0378fbcfd20886ab66ee7602766e72
|
17
17
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
18
18
|
universal-darwin:
|
19
19
|
static:
|
20
|
-
checksum:
|
20
|
+
checksum: dd1ae8d7897edf3112741381226e3622e91553dede6eeae48ca07aae84ac050d
|
21
21
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
22
22
|
dynamic:
|
23
|
-
checksum:
|
23
|
+
checksum: a523a85f76bdb37ffcacbf14279c3c7fed0378fbcfd20886ab66ee7602766e72
|
24
24
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
25
25
|
aarch64-darwin:
|
26
26
|
static:
|
27
|
-
checksum:
|
27
|
+
checksum: cd5175979ec293d0471c71de1fdd00817bea75f800603a1b87931b19471495f3
|
28
28
|
filename: appsignal-aarch64-darwin-all-static.tar.gz
|
29
29
|
dynamic:
|
30
|
-
checksum:
|
30
|
+
checksum: 77503ee5debad5f503719d5fe653f30c3b3bb6624694f48ef03352f575af97c0
|
31
31
|
filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
|
32
32
|
arm64-darwin:
|
33
33
|
static:
|
34
|
-
checksum:
|
34
|
+
checksum: cd5175979ec293d0471c71de1fdd00817bea75f800603a1b87931b19471495f3
|
35
35
|
filename: appsignal-aarch64-darwin-all-static.tar.gz
|
36
36
|
dynamic:
|
37
|
-
checksum:
|
37
|
+
checksum: 77503ee5debad5f503719d5fe653f30c3b3bb6624694f48ef03352f575af97c0
|
38
38
|
filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
|
39
39
|
arm-darwin:
|
40
40
|
static:
|
41
|
-
checksum:
|
41
|
+
checksum: cd5175979ec293d0471c71de1fdd00817bea75f800603a1b87931b19471495f3
|
42
42
|
filename: appsignal-aarch64-darwin-all-static.tar.gz
|
43
43
|
dynamic:
|
44
|
-
checksum:
|
44
|
+
checksum: 77503ee5debad5f503719d5fe653f30c3b3bb6624694f48ef03352f575af97c0
|
45
45
|
filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
|
46
46
|
aarch64-linux:
|
47
47
|
static:
|
48
|
-
checksum:
|
48
|
+
checksum: ae899aba4fa260c1aa1d21cc8f2bf379a2b52596ef2979e9b9b70f0cd54872d4
|
49
49
|
filename: appsignal-aarch64-linux-all-static.tar.gz
|
50
50
|
dynamic:
|
51
|
-
checksum:
|
51
|
+
checksum: 848ab3df66cac4122133145738a380d3e4763e0bcb324cb0d7c0423741751d80
|
52
52
|
filename: appsignal-aarch64-linux-all-dynamic.tar.gz
|
53
53
|
i686-linux:
|
54
54
|
static:
|
55
|
-
checksum:
|
55
|
+
checksum: 3934810379bade5096a5f055450ddd38f60c1bb2fbc05bebcea92f8f7250a81e
|
56
56
|
filename: appsignal-i686-linux-all-static.tar.gz
|
57
57
|
dynamic:
|
58
|
-
checksum:
|
58
|
+
checksum: 2bd5207d0930f9ce262adcb955582c2a022de8872022a0ddd1ea15391339eb55
|
59
59
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
60
60
|
x86-linux:
|
61
61
|
static:
|
62
|
-
checksum:
|
62
|
+
checksum: 3934810379bade5096a5f055450ddd38f60c1bb2fbc05bebcea92f8f7250a81e
|
63
63
|
filename: appsignal-i686-linux-all-static.tar.gz
|
64
64
|
dynamic:
|
65
|
-
checksum:
|
65
|
+
checksum: 2bd5207d0930f9ce262adcb955582c2a022de8872022a0ddd1ea15391339eb55
|
66
66
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
67
67
|
x86_64-linux:
|
68
68
|
static:
|
69
|
-
checksum:
|
69
|
+
checksum: 956288a49717ea61ec303ef4ab52e7bfafea6e575a8bb9839df24b947d22d988
|
70
70
|
filename: appsignal-x86_64-linux-all-static.tar.gz
|
71
71
|
dynamic:
|
72
|
-
checksum:
|
72
|
+
checksum: abf290aa7ad7be1af54889c9dd70cf2f71902359cfc5f5ce64b53b8421914a51
|
73
73
|
filename: appsignal-x86_64-linux-all-dynamic.tar.gz
|
74
74
|
x86_64-linux-musl:
|
75
75
|
static:
|
76
|
-
checksum:
|
76
|
+
checksum: 5f96744692b6b079bd2b97ac6d8d5900123f108a27237664c88a49782b7ba433
|
77
77
|
filename: appsignal-x86_64-linux-musl-all-static.tar.gz
|
78
78
|
dynamic:
|
79
|
-
checksum:
|
79
|
+
checksum: c0a06de99d88a2e045b60d53319e1bbb8633127667fbe9f09e52f2bbaf6fb54d
|
80
80
|
filename: appsignal-x86_64-linux-musl-all-dynamic.tar.gz
|
81
81
|
x86_64-freebsd:
|
82
82
|
static:
|
83
|
-
checksum:
|
83
|
+
checksum: 23ea3fdcc5ae7dfdc85214c872ef928ed702c029b05c059db614583f689b9304
|
84
84
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
85
85
|
dynamic:
|
86
|
-
checksum:
|
86
|
+
checksum: 683cc20296ef05257c4209b3c5d86ef32b76be6ea75a1d1ec76db0163e729a38
|
87
87
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
88
88
|
amd64-freebsd:
|
89
89
|
static:
|
90
|
-
checksum:
|
90
|
+
checksum: 23ea3fdcc5ae7dfdc85214c872ef928ed702c029b05c059db614583f689b9304
|
91
91
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
92
92
|
dynamic:
|
93
|
-
checksum:
|
93
|
+
checksum: 683cc20296ef05257c4209b3c5d86ef32b76be6ea75a1d1ec76db0163e729a38
|
94
94
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
@@ -471,7 +471,8 @@ module Appsignal
|
|
471
471
|
:system => config.system_config,
|
472
472
|
:initial => config.initial_config,
|
473
473
|
:file => config.file_config,
|
474
|
-
:env => config.env_config
|
474
|
+
:env => config.env_config,
|
475
|
+
:override => config.override_config
|
475
476
|
}
|
476
477
|
}
|
477
478
|
print_config_options(config)
|
data/lib/appsignal/config.rb
CHANGED
@@ -170,7 +170,7 @@ module Appsignal
|
|
170
170
|
# @return [Hash]
|
171
171
|
|
172
172
|
attr_reader :root_path, :env, :config_hash, :system_config,
|
173
|
-
:initial_config, :file_config, :env_config
|
173
|
+
:initial_config, :file_config, :env_config, :override_config
|
174
174
|
attr_accessor :logger
|
175
175
|
|
176
176
|
# Initialize a new configuration object for AppSignal.
|
@@ -231,6 +231,9 @@ module Appsignal
|
|
231
231
|
# Load config from environment variables
|
232
232
|
@env_config = load_from_environment
|
233
233
|
merge(env_config)
|
234
|
+
# Load config overrides
|
235
|
+
@override_config = determine_overrides
|
236
|
+
merge(override_config)
|
234
237
|
# Handle deprecated config options
|
235
238
|
maintain_backwards_compatibility
|
236
239
|
# Validate that we have a correct config
|
@@ -396,37 +399,23 @@ module Appsignal
|
|
396
399
|
|
397
400
|
# Maintain backwards compatibility with deprecated config options.
|
398
401
|
#
|
399
|
-
# Add deprecated config options here
|
400
|
-
# replacement,
|
402
|
+
# Add warnings for deprecated config options here if they have no
|
403
|
+
# replacement, or should be non-functional.
|
404
|
+
#
|
405
|
+
# Add them to {determine_overrides} if replacement config options should be
|
406
|
+
# set instead.
|
401
407
|
#
|
402
408
|
# Make sure to remove the contents of this method in the next major
|
403
409
|
# version, but the method itself with an empty body can stick around as a
|
404
410
|
# structure for future deprecations.
|
405
411
|
def maintain_backwards_compatibility
|
406
|
-
|
407
|
-
send_session_data = config_hash[:send_session_data]
|
408
|
-
if skip_session_data.nil? # Deprecated option is not set
|
409
|
-
if send_session_data.nil? # Not configured by user
|
410
|
-
@system_config[:send_session_data] = true
|
411
|
-
merge(:send_session_data => true) # Set default value
|
412
|
-
end
|
413
|
-
else
|
414
|
-
if send_session_data.nil? # Not configured by user
|
415
|
-
@system_config[:send_session_data] = !skip_session_data
|
416
|
-
merge(:send_session_data => !skip_session_data)
|
417
|
-
end
|
418
|
-
deprecation_message "The `skip_session_data` config option is " \
|
419
|
-
"deprecated. Please use `send_session_data` instead.",
|
420
|
-
logger
|
421
|
-
end
|
412
|
+
return unless config_hash.key?(:working_dir_path)
|
422
413
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
logger
|
429
|
-
end
|
414
|
+
deprecation_message \
|
415
|
+
"The `working_dir_path` option is deprecated, please use " \
|
416
|
+
"`working_directory_path` instead and specify the " \
|
417
|
+
"full path to the working directory",
|
418
|
+
logger
|
430
419
|
end
|
431
420
|
|
432
421
|
def load_from_environment
|
@@ -456,6 +445,31 @@ module Appsignal
|
|
456
445
|
config
|
457
446
|
end
|
458
447
|
|
448
|
+
# Set config options based on the final user config. Fix any conflicting
|
449
|
+
# config or set new config options based on deprecated config options.
|
450
|
+
#
|
451
|
+
# Make sure to remove behavior for deprecated config options in this method
|
452
|
+
# in the next major version, but the method itself with an empty body can
|
453
|
+
# stick around as a structure for future deprecations.
|
454
|
+
def determine_overrides
|
455
|
+
config = {}
|
456
|
+
skip_session_data = config_hash[:skip_session_data]
|
457
|
+
send_session_data = config_hash[:send_session_data]
|
458
|
+
if skip_session_data.nil? # Deprecated option is not set
|
459
|
+
if send_session_data.nil? # Not configured by user
|
460
|
+
config[:send_session_data] = true # Set default value
|
461
|
+
end
|
462
|
+
else
|
463
|
+
deprecation_message "The `skip_session_data` config option is " \
|
464
|
+
"deprecated. Please use `send_session_data` instead.",
|
465
|
+
logger
|
466
|
+
# Not configured by user
|
467
|
+
config[:send_session_data] = !skip_session_data if send_session_data.nil?
|
468
|
+
end
|
469
|
+
|
470
|
+
config
|
471
|
+
end
|
472
|
+
|
459
473
|
def merge(new_config)
|
460
474
|
new_config.each do |key, value|
|
461
475
|
unless config_hash[key].nil?
|
@@ -21,28 +21,28 @@ module Appsignal
|
|
21
21
|
},
|
22
22
|
"insert" => {
|
23
23
|
"insert" => :allow,
|
24
|
-
"documents" => :
|
24
|
+
"documents" => :sanitize_document,
|
25
25
|
"ordered" => :allow
|
26
26
|
},
|
27
27
|
"update" => {
|
28
28
|
"update" => :allow,
|
29
|
-
"updates" => :
|
29
|
+
"updates" => :sanitize_document,
|
30
30
|
"ordered" => :allow
|
31
31
|
},
|
32
32
|
"findandmodify" => {
|
33
33
|
"findandmodify" => :allow,
|
34
34
|
"query" => :sanitize_document,
|
35
|
-
"update" => :
|
35
|
+
"update" => :sanitize_document,
|
36
36
|
"new" => :allow
|
37
37
|
},
|
38
38
|
"delete" => {
|
39
39
|
"delete" => :allow,
|
40
|
-
"deletes" => :
|
40
|
+
"deletes" => :sanitize_document,
|
41
41
|
"ordered" => :allow
|
42
42
|
},
|
43
43
|
"bulk" => {
|
44
44
|
"q" => :sanitize_document,
|
45
|
-
"u" => :
|
45
|
+
"u" => :sanitize_document,
|
46
46
|
"limit" => :allow,
|
47
47
|
"multi" => :allow,
|
48
48
|
"upsert" => :allow
|
@@ -68,20 +68,9 @@ module Appsignal
|
|
68
68
|
# Applies strategy on hash values based on keys
|
69
69
|
def self.apply_strategy(strategy, val)
|
70
70
|
case strategy
|
71
|
-
when :allow
|
72
|
-
when :deny then "?"
|
73
|
-
when :deny_array then "[?]"
|
71
|
+
when :allow then val
|
74
72
|
when :sanitize_document
|
75
|
-
Appsignal::Utils::QueryParamsSanitizer.sanitize(val,
|
76
|
-
when :sanitize_bulk
|
77
|
-
if val.length > 1
|
78
|
-
[
|
79
|
-
format(:bulk, val.first),
|
80
|
-
"[...]"
|
81
|
-
]
|
82
|
-
else
|
83
|
-
val.map { |v| format(:bulk, v) }
|
84
|
-
end
|
73
|
+
Appsignal::Utils::QueryParamsSanitizer.sanitize(val, false, :mongodb)
|
85
74
|
else "?"
|
86
75
|
end
|
87
76
|
end
|
@@ -11,8 +11,10 @@ module Appsignal
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def install
|
14
|
-
|
15
|
-
|
14
|
+
ActiveSupport.on_load(:active_job) do
|
15
|
+
::ActiveJob::Base
|
16
|
+
.extend ::Appsignal::Hooks::ActiveJobHook::ActiveJobClassInstrumentation
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
module ActiveJobClassInstrumentation
|
@@ -35,7 +35,7 @@ module Appsignal
|
|
35
35
|
|
36
36
|
def sanitize_array(array, only_top_level, key_sanitizer)
|
37
37
|
if only_top_level
|
38
|
-
sanitize(array[0], only_top_level, key_sanitizer)
|
38
|
+
[sanitize(array[0], only_top_level, key_sanitizer)]
|
39
39
|
else
|
40
40
|
array.map do |value|
|
41
41
|
sanitize(value, only_top_level, key_sanitizer)
|
data/lib/appsignal/version.rb
CHANGED
data/lib/appsignal.rb
CHANGED
@@ -58,20 +58,6 @@ module Appsignal
|
|
58
58
|
# @see start_logger
|
59
59
|
attr_writer :logger
|
60
60
|
|
61
|
-
# @api private
|
62
|
-
def extensions
|
63
|
-
@extensions ||= []
|
64
|
-
end
|
65
|
-
|
66
|
-
# @api private
|
67
|
-
def initialize_extensions
|
68
|
-
Appsignal.logger.debug("Initializing extensions")
|
69
|
-
extensions.each do |extension|
|
70
|
-
Appsignal.logger.debug("Initializing #{extension}")
|
71
|
-
extension.initializer
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
61
|
# @api private
|
76
62
|
def testing?
|
77
63
|
false
|
@@ -123,7 +109,6 @@ module Appsignal
|
|
123
109
|
config.write_to_environment
|
124
110
|
Appsignal::Extension.start
|
125
111
|
Appsignal::Hooks.load_hooks
|
126
|
-
initialize_extensions
|
127
112
|
|
128
113
|
if config[:enable_allocation_tracking] && !Appsignal::System.jruby?
|
129
114
|
Appsignal::Extension.install_allocation_event_hook
|
@@ -772,10 +772,11 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
772
772
|
"options" => default_config.merge("env" => "", "send_session_data" => true),
|
773
773
|
"sources" => {
|
774
774
|
"default" => default_config,
|
775
|
-
"system" => {
|
775
|
+
"system" => {},
|
776
776
|
"initial" => { "env" => "" },
|
777
777
|
"file" => {},
|
778
|
-
"env" => {}
|
778
|
+
"env" => {},
|
779
|
+
"override" => { "send_session_data" => true }
|
779
780
|
}
|
780
781
|
)
|
781
782
|
end
|
@@ -890,10 +891,11 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
890
891
|
"options" => hash_with_string_keys(final_config),
|
891
892
|
"sources" => {
|
892
893
|
"default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
|
893
|
-
"system" => {
|
894
|
+
"system" => {},
|
894
895
|
"initial" => hash_with_string_keys(config.initial_config.merge(additional_initial_config)),
|
895
896
|
"file" => hash_with_string_keys(config.file_config),
|
896
|
-
"env" => {}
|
897
|
+
"env" => {},
|
898
|
+
"override" => { "send_session_data" => true }
|
897
899
|
}
|
898
900
|
)
|
899
901
|
end
|
@@ -917,10 +919,11 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
917
919
|
"options" => hash_with_string_keys(config.config_hash).merge("env" => "foobar"),
|
918
920
|
"sources" => {
|
919
921
|
"default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
|
920
|
-
"system" => {
|
922
|
+
"system" => {},
|
921
923
|
"initial" => hash_with_string_keys(config.initial_config),
|
922
924
|
"file" => hash_with_string_keys(config.file_config),
|
923
|
-
"env" => {}
|
925
|
+
"env" => {},
|
926
|
+
"override" => { "send_session_data" => true }
|
924
927
|
}
|
925
928
|
)
|
926
929
|
end
|
@@ -434,6 +434,87 @@ describe Appsignal::Config do
|
|
434
434
|
end
|
435
435
|
end
|
436
436
|
|
437
|
+
describe "with config based on overrides" do
|
438
|
+
let(:log_stream) { StringIO.new }
|
439
|
+
let(:logger) { test_logger(log_stream) }
|
440
|
+
let(:logs) { log_contents(log_stream) }
|
441
|
+
let(:config) do
|
442
|
+
described_class.new(Dir.pwd, "production", config_options, logger)
|
443
|
+
end
|
444
|
+
|
445
|
+
describe "skip_session_data" do
|
446
|
+
let(:err_stream) { std_stream }
|
447
|
+
let(:stderr) { err_stream.read }
|
448
|
+
let(:deprecation_message) do
|
449
|
+
"The `skip_session_data` config option is deprecated. Please use " \
|
450
|
+
"`send_session_data` instead."
|
451
|
+
end
|
452
|
+
before do
|
453
|
+
capture_std_streams(std_stream, err_stream) { config }
|
454
|
+
end
|
455
|
+
|
456
|
+
context "when not set" do
|
457
|
+
let(:config_options) { {} }
|
458
|
+
|
459
|
+
it "sets the default send_session_data value" do
|
460
|
+
expect(config[:skip_session_data]).to be_nil
|
461
|
+
expect(config[:send_session_data]).to eq(true)
|
462
|
+
expect(config.override_config[:send_session_data]).to eq(true)
|
463
|
+
end
|
464
|
+
|
465
|
+
it "does not print a deprecation warning" do
|
466
|
+
expect(stderr).to_not include("appsignal WARNING: #{deprecation_message}")
|
467
|
+
expect(logs).to_not include(deprecation_message)
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
context "when set to true" do
|
472
|
+
let(:config_options) { { :skip_session_data => true } }
|
473
|
+
|
474
|
+
it "sets send_session_data if send_session_data is not set by the user" do
|
475
|
+
expect(config[:skip_session_data]).to eq(true)
|
476
|
+
expect(config[:send_session_data]).to eq(false)
|
477
|
+
expect(config.override_config[:send_session_data]).to eq(false)
|
478
|
+
end
|
479
|
+
|
480
|
+
it "prints a deprecation warning" do
|
481
|
+
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
482
|
+
expect(logs).to include(deprecation_message)
|
483
|
+
end
|
484
|
+
end
|
485
|
+
|
486
|
+
context "when set to false" do
|
487
|
+
let(:config_options) { { :skip_session_data => false } }
|
488
|
+
|
489
|
+
it "sets send_session_data if send_session_data is not set by the user" do
|
490
|
+
expect(config[:skip_session_data]).to eq(false)
|
491
|
+
expect(config[:send_session_data]).to eq(true)
|
492
|
+
expect(config.override_config[:send_session_data]).to eq(true)
|
493
|
+
end
|
494
|
+
|
495
|
+
it "prints a deprecation warning" do
|
496
|
+
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
497
|
+
expect(logs).to include(deprecation_message)
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
context "when skip_session_data and send_session_data are both set" do
|
502
|
+
let(:config_options) { { :skip_session_data => true, :send_session_data => true } }
|
503
|
+
|
504
|
+
it "does not overwrite the send_session_data value" do
|
505
|
+
expect(config[:skip_session_data]).to eq(true)
|
506
|
+
expect(config[:send_session_data]).to eq(true)
|
507
|
+
expect(config.override_config[:send_session_data]).to be_nil
|
508
|
+
end
|
509
|
+
|
510
|
+
it "prints a deprecation warning" do
|
511
|
+
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
512
|
+
expect(logs).to include(deprecation_message)
|
513
|
+
end
|
514
|
+
end
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
437
518
|
describe "config keys" do
|
438
519
|
describe ":endpoint" do
|
439
520
|
subject { config[:endpoint] }
|
@@ -789,78 +870,6 @@ describe Appsignal::Config do
|
|
789
870
|
end
|
790
871
|
end
|
791
872
|
end
|
792
|
-
|
793
|
-
describe "skip_session_data" do
|
794
|
-
let(:err_stream) { std_stream }
|
795
|
-
let(:stderr) { err_stream.read }
|
796
|
-
let(:deprecation_message) do
|
797
|
-
"The `skip_session_data` config option is deprecated. Please use " \
|
798
|
-
"`send_session_data` instead."
|
799
|
-
end
|
800
|
-
before do
|
801
|
-
capture_std_streams(std_stream, err_stream) { config }
|
802
|
-
end
|
803
|
-
|
804
|
-
context "when not set" do
|
805
|
-
let(:config_options) { {} }
|
806
|
-
|
807
|
-
it "sets the default send_session_data value" do
|
808
|
-
expect(config[:skip_session_data]).to be_nil
|
809
|
-
expect(config[:send_session_data]).to eq(true)
|
810
|
-
expect(config.system_config[:send_session_data]).to eq(true)
|
811
|
-
end
|
812
|
-
|
813
|
-
it "does not print a deprecation warning" do
|
814
|
-
expect(stderr).to_not include("appsignal WARNING: #{deprecation_message}")
|
815
|
-
expect(logs).to_not include(deprecation_message)
|
816
|
-
end
|
817
|
-
end
|
818
|
-
|
819
|
-
context "when set to true" do
|
820
|
-
let(:config_options) { { :skip_session_data => true } }
|
821
|
-
|
822
|
-
it "sets send_session_data if send_session_data is not set by the user" do
|
823
|
-
expect(config[:skip_session_data]).to eq(true)
|
824
|
-
expect(config[:send_session_data]).to eq(false)
|
825
|
-
expect(config.system_config[:send_session_data]).to eq(false)
|
826
|
-
end
|
827
|
-
|
828
|
-
it "prints a deprecation warning" do
|
829
|
-
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
830
|
-
expect(logs).to include(deprecation_message)
|
831
|
-
end
|
832
|
-
end
|
833
|
-
|
834
|
-
context "when set to false" do
|
835
|
-
let(:config_options) { { :skip_session_data => false } }
|
836
|
-
|
837
|
-
it "sets send_session_data if send_session_data is not set by the user" do
|
838
|
-
expect(config[:skip_session_data]).to eq(false)
|
839
|
-
expect(config[:send_session_data]).to eq(true)
|
840
|
-
expect(config.system_config[:send_session_data]).to eq(true)
|
841
|
-
end
|
842
|
-
|
843
|
-
it "prints a deprecation warning" do
|
844
|
-
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
845
|
-
expect(logs).to include(deprecation_message)
|
846
|
-
end
|
847
|
-
end
|
848
|
-
|
849
|
-
context "when skip_session_data and send_session_data are both set" do
|
850
|
-
let(:config_options) { { :skip_session_data => true, :send_session_data => true } }
|
851
|
-
|
852
|
-
it "does not overwrite the send_session_data value" do
|
853
|
-
expect(config[:skip_session_data]).to eq(true)
|
854
|
-
expect(config[:send_session_data]).to eq(true)
|
855
|
-
expect(config.system_config[:send_session_data]).to be_nil
|
856
|
-
end
|
857
|
-
|
858
|
-
it "prints a deprecation warning" do
|
859
|
-
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
860
|
-
expect(logs).to include(deprecation_message)
|
861
|
-
end
|
862
|
-
end
|
863
|
-
end
|
864
873
|
end
|
865
874
|
|
866
875
|
describe "#validate" do
|
@@ -11,8 +11,12 @@ describe Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should apply a strategy for each key" do
|
14
|
+
# TODO: additional curly brackets required for issue
|
15
|
+
# https://github.com/rspec/rspec-mocks/issues/1460
|
16
|
+
# rubocop:disable Style/BracesAroundHashParameters
|
14
17
|
expect(formatter).to receive(:apply_strategy)
|
15
|
-
.with(:sanitize_document, "_id" => 1)
|
18
|
+
.with(:sanitize_document, { "_id" => 1 })
|
19
|
+
# rubocop:enable Style/BracesAroundHashParameters
|
16
20
|
|
17
21
|
expect(formatter).to receive(:apply_strategy)
|
18
22
|
.with(:allow, "users")
|
@@ -47,57 +51,27 @@ describe Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter do
|
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
50
|
-
context "when strategy is deny" do
|
51
|
-
let(:strategy) { :deny }
|
52
|
-
let(:value) { { "_id" => 1 } }
|
53
|
-
|
54
|
-
it "should return a '?'" do
|
55
|
-
expect(formatter.apply_strategy(strategy, value)).to eql("?")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "when strategy is deny_array" do
|
60
|
-
let(:strategy) { :deny_array }
|
61
|
-
let(:value) { { "_id" => 1 } }
|
62
|
-
|
63
|
-
it "should return a sanitized array string" do
|
64
|
-
expect(formatter.apply_strategy(strategy, value)).to eql("[?]")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
54
|
context "when strategy is sanitize_document" do
|
69
55
|
let(:strategy) { :sanitize_document }
|
70
|
-
let(:value)
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
let(:value) { [{ "q" => { "_id" => 1 }, "u" => [{ "foo" => "bar" }] }] }
|
80
|
-
|
81
|
-
it "should return an array of sanitized bulk documents" do
|
82
|
-
expect(formatter.apply_strategy(strategy, value)).to eql([
|
83
|
-
{ "q" => { "_id" => "?" }, "u" => "[?]" }
|
84
|
-
])
|
56
|
+
let(:value) do
|
57
|
+
{
|
58
|
+
"_id" => 1,
|
59
|
+
"authors" => [
|
60
|
+
{ "name" => "BarBaz" },
|
61
|
+
{ "name" => "FooBar" },
|
62
|
+
{ "name" => "BarFoo", "surname" => "Baz" }
|
63
|
+
]
|
64
|
+
}
|
85
65
|
end
|
86
66
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
{ "
|
67
|
+
it "should return a sanitized document" do
|
68
|
+
expect(formatter.apply_strategy(strategy, value)).to eql(
|
69
|
+
"_id" => "?",
|
70
|
+
"authors" => [
|
71
|
+
{ "name" => "?" },
|
72
|
+
{ "name" => "?", "surname" => "?" }
|
92
73
|
]
|
93
|
-
|
94
|
-
|
95
|
-
it "should return only the first value of sanitized bulk documents" do
|
96
|
-
expect(formatter.apply_strategy(strategy, value)).to eql([
|
97
|
-
{ "q" => { "_id" => "?" }, "u" => "[?]" },
|
98
|
-
"[...]"
|
99
|
-
])
|
100
|
-
end
|
74
|
+
)
|
101
75
|
end
|
102
76
|
end
|
103
77
|
|
@@ -76,7 +76,7 @@ describe Appsignal::EventFormatter::Moped::QueryFormatter do
|
|
76
76
|
)
|
77
77
|
end
|
78
78
|
|
79
|
-
it { is_expected.to eq ["Insert", '{:database=>"database.collection", :documents=>{"_id"=>"?", "events"=>"?"}, :count=>2, :flags=>[]}'] }
|
79
|
+
it { is_expected.to eq ["Insert", '{:database=>"database.collection", :documents=>[{"_id"=>"?", "events"=>"?"}], :count=>2, :flags=>[]}'] }
|
80
80
|
end
|
81
81
|
|
82
82
|
context "Moped::Protocol::Update" do
|
@@ -17,8 +17,12 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should sanitize command" do
|
20
|
+
# TODO: additional curly brackets required for issue
|
21
|
+
# https://github.com/rspec/rspec-mocks/issues/1460
|
22
|
+
# rubocop:disable Style/BracesAroundHashParameters
|
20
23
|
expect(Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter)
|
21
|
-
.to receive(:format).with("find", "foo" => "bar")
|
24
|
+
.to receive(:format).with("find", { "foo" => "bar" })
|
25
|
+
# rubocop:enable Style/BracesAroundHashParameters
|
22
26
|
|
23
27
|
subscriber.started(event)
|
24
28
|
end
|
@@ -148,7 +148,7 @@ if DependencyHelper.padrino_present?
|
|
148
148
|
expect_a_transaction_to_be_created
|
149
149
|
# Uses path for action name
|
150
150
|
expect(transaction).to receive(:set_action_if_nil).with("PadrinoTestApp#unknown")
|
151
|
-
expect(response).to match_response(404,
|
151
|
+
expect(response).to match_response(404, /^GET /404/)
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
@@ -228,10 +228,14 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
|
|
228
228
|
let(:error) { ExampleException }
|
229
229
|
|
230
230
|
it "creates a transaction and adds the error" do
|
231
|
+
# TODO: additional curly brackets required for issue
|
232
|
+
# https://github.com/rspec/rspec-mocks/issues/1460
|
233
|
+
# rubocop:disable Style/BracesAroundHashParameters
|
231
234
|
expect(Appsignal).to receive(:increment_counter)
|
232
|
-
.with("sidekiq_queue_job_count", 1, :queue => "default", :status => :failed)
|
235
|
+
.with("sidekiq_queue_job_count", 1, { :queue => "default", :status => :failed })
|
233
236
|
expect(Appsignal).to receive(:increment_counter)
|
234
|
-
.with("sidekiq_queue_job_count", 1, :queue => "default", :status => :processed)
|
237
|
+
.with("sidekiq_queue_job_count", 1, { :queue => "default", :status => :processed })
|
238
|
+
# rubocop:enable Style/BracesAroundHashParameters
|
235
239
|
|
236
240
|
expect do
|
237
241
|
perform_job { raise error, "uh oh" }
|
@@ -267,8 +271,12 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
|
|
267
271
|
|
268
272
|
context "without an error" do
|
269
273
|
it "creates a transaction with events" do
|
274
|
+
# TODO: additional curly brackets required for issue
|
275
|
+
# https://github.com/rspec/rspec-mocks/issues/1460
|
276
|
+
# rubocop:disable Style/BracesAroundHashParameters
|
270
277
|
expect(Appsignal).to receive(:increment_counter)
|
271
|
-
.with("sidekiq_queue_job_count", 1, :queue => "default", :status => :processed)
|
278
|
+
.with("sidekiq_queue_job_count", 1, { :queue => "default", :status => :processed })
|
279
|
+
# rubocop:enable Style/BracesAroundHashParameters
|
272
280
|
|
273
281
|
perform_job
|
274
282
|
|
@@ -33,7 +33,7 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
33
33
|
let(:value) { ["foo" => "bar"] }
|
34
34
|
|
35
35
|
it "should sanitize all hash values with a questionmark" do
|
36
|
-
expect(subject).to eq("foo" => "?")
|
36
|
+
expect(subject).to eq(["foo" => "?"])
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should not modify source value" do
|
@@ -45,8 +45,8 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
45
45
|
context "when value is an array" do
|
46
46
|
let(:value) { %w[foo bar] }
|
47
47
|
|
48
|
-
it "
|
49
|
-
expect(subject).to eq("?")
|
48
|
+
it "sanitizes all array values" do
|
49
|
+
expect(subject).to eq(["?"])
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should not modify source value" do
|
@@ -58,8 +58,8 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
58
58
|
context "when value is a mixed array" do
|
59
59
|
let(:value) { [nil, "foo", "bar"] }
|
60
60
|
|
61
|
-
it "should sanitize all
|
62
|
-
expect(subject).to eq("?")
|
61
|
+
it "should sanitize all array values with a single questionmark" do
|
62
|
+
expect(subject).to eq(["?"])
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -117,7 +117,7 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
117
117
|
context "when value is an array" do
|
118
118
|
let(:value) { %w[foo bar] }
|
119
119
|
|
120
|
-
it "should sanitize all hash values with a single
|
120
|
+
it "should sanitize all hash values with a single question mark" do
|
121
121
|
expect(subject).to eq(["?"])
|
122
122
|
end
|
123
123
|
end
|
@@ -125,7 +125,7 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
125
125
|
context "when value is a mixed array" do
|
126
126
|
let(:value) { [nil, "foo", "bar"] }
|
127
127
|
|
128
|
-
it "should sanitize all hash values with a single
|
128
|
+
it "should sanitize all hash values with a single question mark" do
|
129
129
|
expect(subject).to eq(["?"])
|
130
130
|
end
|
131
131
|
end
|
data/spec/lib/appsignal_spec.rb
CHANGED
@@ -5,7 +5,6 @@ describe Appsignal do
|
|
5
5
|
# Make sure we have a clean state because we want to test
|
6
6
|
# initialization here.
|
7
7
|
Appsignal.config = nil
|
8
|
-
Appsignal.extensions.clear
|
9
8
|
end
|
10
9
|
|
11
10
|
let(:transaction) { http_request_transaction }
|
@@ -20,14 +19,6 @@ describe Appsignal do
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
describe ".extensions" do
|
24
|
-
it "should keep a list of extensions" do
|
25
|
-
expect(Appsignal.extensions).to be_empty
|
26
|
-
Appsignal.extensions << Appsignal::MockExtension
|
27
|
-
expect(Appsignal.extensions.size).to eq(1)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
22
|
describe ".start" do
|
32
23
|
context "with no config set beforehand" do
|
33
24
|
it "should do nothing when config is not set and there is no valid config in the env" do
|
@@ -63,15 +54,6 @@ describe Appsignal do
|
|
63
54
|
Appsignal.start
|
64
55
|
end
|
65
56
|
|
66
|
-
context "with an extension" do
|
67
|
-
before { Appsignal.extensions << Appsignal::MockExtension }
|
68
|
-
|
69
|
-
it "should call the extension's initializer" do
|
70
|
-
expect(Appsignal::MockExtension).to receive(:initializer)
|
71
|
-
Appsignal.start
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
57
|
context "when allocation tracking and gc instrumentation have been enabled" do
|
76
58
|
before do
|
77
59
|
allow(GC::Profiler).to receive(:enable)
|
@@ -427,49 +409,89 @@ describe Appsignal do
|
|
427
409
|
end
|
428
410
|
|
429
411
|
describe ".monitor_single_transaction" do
|
412
|
+
around { |example| keep_transactions { example.run } }
|
413
|
+
|
430
414
|
context "with a successful call" do
|
431
|
-
it "
|
432
|
-
expect(Appsignal).to receive(:monitor_transaction).with(
|
433
|
-
"perform_job.something",
|
434
|
-
:key => :value
|
435
|
-
).and_yield
|
415
|
+
it "calls monitor_transaction and Appsignal.stop" do
|
436
416
|
expect(Appsignal).to receive(:stop)
|
437
417
|
|
438
|
-
Appsignal.monitor_single_transaction(
|
418
|
+
Appsignal.monitor_single_transaction(
|
419
|
+
"perform_job.something",
|
420
|
+
:controller => :my_controller,
|
421
|
+
:action => :my_action
|
422
|
+
) do
|
439
423
|
# nothing
|
440
424
|
end
|
425
|
+
|
426
|
+
transaction = last_transaction
|
427
|
+
transaction_hash = transaction.to_h
|
428
|
+
expect(transaction_hash).to include(
|
429
|
+
"action" => "my_controller#my_action"
|
430
|
+
)
|
431
|
+
expect(transaction_hash["events"]).to match([
|
432
|
+
hash_including(
|
433
|
+
"name" => "perform_job.something",
|
434
|
+
"title" => "",
|
435
|
+
"body" => "",
|
436
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT
|
437
|
+
)
|
438
|
+
])
|
441
439
|
end
|
442
440
|
end
|
443
441
|
|
444
442
|
context "with an erroring call" do
|
445
443
|
let(:error) { ExampleException.new }
|
446
444
|
|
447
|
-
it "
|
448
|
-
expect(Appsignal).to receive(:monitor_transaction).with(
|
449
|
-
"perform_job.something",
|
450
|
-
:key => :value
|
451
|
-
).and_yield
|
445
|
+
it "calls monitor_transaction and stop and re-raises the error" do
|
452
446
|
expect(Appsignal).to receive(:stop)
|
453
447
|
|
454
448
|
expect do
|
455
|
-
Appsignal.monitor_single_transaction(
|
449
|
+
Appsignal.monitor_single_transaction(
|
450
|
+
"perform_job.something",
|
451
|
+
:controller => :my_controller,
|
452
|
+
:action => :my_action
|
453
|
+
) do
|
456
454
|
raise error
|
457
455
|
end
|
458
456
|
end.to raise_error(error)
|
457
|
+
|
458
|
+
transaction = last_transaction
|
459
|
+
transaction_hash = transaction.to_h
|
460
|
+
expect(transaction_hash).to include(
|
461
|
+
"action" => "my_controller#my_action"
|
462
|
+
)
|
463
|
+
expect(transaction_hash["events"]).to match([
|
464
|
+
hash_including(
|
465
|
+
"name" => "perform_job.something",
|
466
|
+
"title" => "",
|
467
|
+
"body" => "",
|
468
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT
|
469
|
+
)
|
470
|
+
])
|
459
471
|
end
|
460
472
|
end
|
461
473
|
end
|
462
474
|
|
463
475
|
describe ".tag_request" do
|
464
|
-
|
476
|
+
let(:transaction) { http_request_transaction }
|
477
|
+
around do |example|
|
478
|
+
start_agent
|
479
|
+
with_current_transaction transaction do
|
480
|
+
keep_transactions { example.run }
|
481
|
+
end
|
482
|
+
end
|
465
483
|
|
466
484
|
context "with transaction" do
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
end
|
485
|
+
it "calls set_tags on the current transaction" do
|
486
|
+
Appsignal.tag_request("a" => "b")
|
487
|
+
transaction.complete # Manually trigger transaction sampling
|
471
488
|
|
472
|
-
|
489
|
+
expect(transaction.to_h).to include(
|
490
|
+
"sample_data" => hash_including(
|
491
|
+
"tags" => { "a" => "b" }
|
492
|
+
)
|
493
|
+
)
|
494
|
+
end
|
473
495
|
end
|
474
496
|
|
475
497
|
context "without transaction" do
|
@@ -56,6 +56,16 @@ module TransactionHelpers
|
|
56
56
|
Thread.current[:appsignal_transaction] = nil
|
57
57
|
end
|
58
58
|
|
59
|
+
# Set the current for the duration of the given block.
|
60
|
+
#
|
61
|
+
# Helper for {set_current_transaction} and {clear_current_transaction!}
|
62
|
+
def with_current_transaction(transaction)
|
63
|
+
set_current_transaction transaction
|
64
|
+
yield
|
65
|
+
ensure
|
66
|
+
clear_current_transaction!
|
67
|
+
end
|
68
|
+
|
59
69
|
# Track the AppSignal transaction JSON when a transaction gets completed
|
60
70
|
# ({Appsignal::Transaction.complete}).
|
61
71
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-02-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -30,16 +30,16 @@ dependencies:
|
|
30
30
|
name: rake
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - "
|
33
|
+
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '12'
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - "
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '12'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rspec
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -391,7 +391,6 @@ files:
|
|
391
391
|
- spec/support/matchers/contains_log.rb
|
392
392
|
- spec/support/matchers/have_colorized_text.rb
|
393
393
|
- spec/support/mocks/fake_gc_profiler.rb
|
394
|
-
- spec/support/mocks/mock_extension.rb
|
395
394
|
- spec/support/mocks/mock_probe.rb
|
396
395
|
- spec/support/rails/my_app.rb
|
397
396
|
- spec/support/shared_examples/instrument.rb
|
@@ -405,6 +404,7 @@ homepage: https://github.com/appsignal/appsignal-ruby
|
|
405
404
|
licenses:
|
406
405
|
- MIT
|
407
406
|
metadata:
|
407
|
+
rubygems_mfa_required: 'true'
|
408
408
|
bug_tracker_uri: https://github.com/appsignal/appsignal-ruby/issues
|
409
409
|
changelog_uri: https://github.com/appsignal/appsignal-ruby/blob/main/CHANGELOG.md
|
410
410
|
documentation_uri: https://docs.appsignal.com/ruby/
|
@@ -426,7 +426,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
426
426
|
- !ruby/object:Gem::Version
|
427
427
|
version: '0'
|
428
428
|
requirements: []
|
429
|
-
rubygems_version: 3.3.
|
429
|
+
rubygems_version: 3.3.6
|
430
430
|
signing_key:
|
431
431
|
specification_version: 4
|
432
432
|
summary: Logs performance and exception data from your app to appsignal.com
|
@@ -544,7 +544,6 @@ test_files:
|
|
544
544
|
- spec/support/matchers/contains_log.rb
|
545
545
|
- spec/support/matchers/have_colorized_text.rb
|
546
546
|
- spec/support/mocks/fake_gc_profiler.rb
|
547
|
-
- spec/support/mocks/mock_extension.rb
|
548
547
|
- spec/support/mocks/mock_probe.rb
|
549
548
|
- spec/support/rails/my_app.rb
|
550
549
|
- spec/support/shared_examples/instrument.rb
|