appsignal 3.0.19-java → 3.0.22-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/appsignal.gemspec +1 -0
- data/ext/agent.yml +25 -25
- data/ext/base.rb +1 -1
- data/lib/appsignal/cli/diagnose.rb +3 -2
- data/lib/appsignal/config.rb +54 -21
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +7 -18
- data/lib/appsignal/transaction.rb +2 -2
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +0 -15
- data/spec/lib/appsignal/cli/diagnose_spec.rb +10 -7
- data/spec/lib/appsignal/config_spec.rb +138 -9
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +21 -47
- 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/transaction_spec.rb +2 -2
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +2 -2
- data/spec/lib/appsignal_spec.rb +58 -36
- data/spec/support/helpers/transaction_helpers.rb +10 -0
- metadata +4 -5
- 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: 61dc2deb7f2fb68c80c83b94d911f9c11b7af516b38c125b4da3effb1e46edc4
|
4
|
+
data.tar.gz: d784f570079e3fa8fb4938866d3d0dcf9b37f91c351456821921a6881065feba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79f7922982a074b50c42d58afed577ee808a7e1da9bce765b74472acbb487cd2de29ff3b6ee0e2b26126ec3c07f96bb10f140ed1c5eb8a23702d6d5d3d10d064
|
7
|
+
data.tar.gz: a2d13999e2f73f8173866fba3fa6b5de0226fa966f8345bf54f25c548a0b7a6314093b69d43dc465b361e998f7919f59c71a45cb4f155cf580f4c82c094cdaa4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,49 @@
|
|
1
1
|
# AppSignal for Ruby gem Changelog
|
2
2
|
|
3
|
+
## 3.0.22
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
|
7
|
+
- [9762e79d](https://github.com/appsignal/appsignal-ruby/commit/9762e79d4545e50c8f3540deff825b10d77e59a5) patch - Bump agent to v-bbc830a
|
8
|
+
|
9
|
+
- Support batched statsd messages
|
10
|
+
- Set start times for spans with traceparents
|
11
|
+
- Check duration in transactions for negative and too high value
|
12
|
+
|
13
|
+
## 3.0.21
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- [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.
|
18
|
+
|
19
|
+
### Removed
|
20
|
+
|
21
|
+
- [3f503ade](https://github.com/appsignal/appsignal-ruby/commit/3f503ade83f22f4b0d86d76ea00e5f4dd3c56b6f) patch - Remove internal `Appsignal.extensions` system. It was unused.
|
22
|
+
|
23
|
+
## 3.0.21.alpha.1
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
|
27
|
+
- [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.
|
28
|
+
Only the actual values are filtered with a `?` character. Less MongoDB queries are now marked
|
29
|
+
as N+1 queries when they weren't the exact same query. This increases the number of unique events
|
30
|
+
AppSignal tracks for MongoDB queries.
|
31
|
+
|
32
|
+
## 3.0.20
|
33
|
+
|
34
|
+
### Added
|
35
|
+
|
36
|
+
- [35bd83b8](https://github.com/appsignal/appsignal-ruby/commit/35bd83b84fd30f0188d9f134cfd249360b6e281d) patch - Add `send_session_data` option to configure if session data is automatically included transactions. By default this is turned on. It can be disabled by configuring `send_session_data` to `false`.
|
37
|
+
|
38
|
+
### Deprecated
|
39
|
+
|
40
|
+
- [35bd83b8](https://github.com/appsignal/appsignal-ruby/commit/35bd83b84fd30f0188d9f134cfd249360b6e281d) patch - Deprecate `skip_session_data` option in favor of the newly introduced `send_session_data` option. If it is configured it will print a warning on AppSignal load, but will also retain its functionality until the config option is fully removed in the next major release.
|
41
|
+
- [e51a8fb6](https://github.com/appsignal/appsignal-ruby/commit/e51a8fb653fccc5a6b72ac7af9c9417e6827e2e9) patch - Warn about the deprecated `working_dir_path` option from all config sources. It previously only printed a warning when it was configured in the `config/appsignal.yml` file, but now also prints the warning if it's set via the Config class initialize options and environment variables. Please use the `working_directory_path` option instead.
|
42
|
+
|
43
|
+
### Fixed
|
44
|
+
|
45
|
+
- [c9000eee](https://github.com/appsignal/appsignal-ruby/commit/c9000eeefec722cb940b2e14f37d31a7827986d6) patch - Fix reported Ruby version in diagnose report. It would report only the first major release of the series, e.g. 2.6.0 for 2.6.1.
|
46
|
+
|
3
47
|
## 3.0.19
|
4
48
|
|
5
49
|
### Changed
|
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",
|
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: bbc830a
|
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: 5e817193bb57f13ff16bacceda459d8badc2d5a04a6b131a7bb343212329304a
|
14
14
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
15
15
|
dynamic:
|
16
|
-
checksum:
|
16
|
+
checksum: 641a499de4dd2a0ebc92d0d28ea98bf9c8387ee7393d093ba2f83a64d522d162
|
17
17
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
18
18
|
universal-darwin:
|
19
19
|
static:
|
20
|
-
checksum:
|
20
|
+
checksum: 5e817193bb57f13ff16bacceda459d8badc2d5a04a6b131a7bb343212329304a
|
21
21
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
22
22
|
dynamic:
|
23
|
-
checksum:
|
23
|
+
checksum: 641a499de4dd2a0ebc92d0d28ea98bf9c8387ee7393d093ba2f83a64d522d162
|
24
24
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
25
25
|
aarch64-darwin:
|
26
26
|
static:
|
27
|
-
checksum:
|
27
|
+
checksum: d443e00232acd3e53cd3d3f8c525da69ad362c38230472cc596e687cf73c7d94
|
28
28
|
filename: appsignal-aarch64-darwin-all-static.tar.gz
|
29
29
|
dynamic:
|
30
|
-
checksum:
|
30
|
+
checksum: 750cbaf06fca0a46e0ad046823a5b55b461cdff4bd4882383d22b0c60d4e434e
|
31
31
|
filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
|
32
32
|
arm64-darwin:
|
33
33
|
static:
|
34
|
-
checksum:
|
34
|
+
checksum: d443e00232acd3e53cd3d3f8c525da69ad362c38230472cc596e687cf73c7d94
|
35
35
|
filename: appsignal-aarch64-darwin-all-static.tar.gz
|
36
36
|
dynamic:
|
37
|
-
checksum:
|
37
|
+
checksum: 750cbaf06fca0a46e0ad046823a5b55b461cdff4bd4882383d22b0c60d4e434e
|
38
38
|
filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
|
39
39
|
arm-darwin:
|
40
40
|
static:
|
41
|
-
checksum:
|
41
|
+
checksum: d443e00232acd3e53cd3d3f8c525da69ad362c38230472cc596e687cf73c7d94
|
42
42
|
filename: appsignal-aarch64-darwin-all-static.tar.gz
|
43
43
|
dynamic:
|
44
|
-
checksum:
|
44
|
+
checksum: 750cbaf06fca0a46e0ad046823a5b55b461cdff4bd4882383d22b0c60d4e434e
|
45
45
|
filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
|
46
46
|
aarch64-linux:
|
47
47
|
static:
|
48
|
-
checksum:
|
48
|
+
checksum: 7cd884dfd47466112d571ce49830057ffff0070383037eec4bfecf29547e3e47
|
49
49
|
filename: appsignal-aarch64-linux-all-static.tar.gz
|
50
50
|
dynamic:
|
51
|
-
checksum:
|
51
|
+
checksum: 060c7b768c7bd81aaf0dd9a872d4bd36f1efd433972ae5cab41e2791236a3d0c
|
52
52
|
filename: appsignal-aarch64-linux-all-dynamic.tar.gz
|
53
53
|
i686-linux:
|
54
54
|
static:
|
55
|
-
checksum:
|
55
|
+
checksum: 21ca02f85c438190307b2a3500642a94dbd35ada6349cd97ac32253ac7dcc9e1
|
56
56
|
filename: appsignal-i686-linux-all-static.tar.gz
|
57
57
|
dynamic:
|
58
|
-
checksum:
|
58
|
+
checksum: 2cf89679e62b725374e8578bb58dcfea30c573e406bd28f42215be52a2c8f31e
|
59
59
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
60
60
|
x86-linux:
|
61
61
|
static:
|
62
|
-
checksum:
|
62
|
+
checksum: 21ca02f85c438190307b2a3500642a94dbd35ada6349cd97ac32253ac7dcc9e1
|
63
63
|
filename: appsignal-i686-linux-all-static.tar.gz
|
64
64
|
dynamic:
|
65
|
-
checksum:
|
65
|
+
checksum: 2cf89679e62b725374e8578bb58dcfea30c573e406bd28f42215be52a2c8f31e
|
66
66
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
67
67
|
x86_64-linux:
|
68
68
|
static:
|
69
|
-
checksum:
|
69
|
+
checksum: 6feb2ed89451c6fdf6365dd1023bd419d8fa99e3c986d6a4e804f8cb68b3f401
|
70
70
|
filename: appsignal-x86_64-linux-all-static.tar.gz
|
71
71
|
dynamic:
|
72
|
-
checksum:
|
72
|
+
checksum: e8dc655eaf5194dade1b5b20fc2bed0b443db84bfaf9c1828875a77dd20516c9
|
73
73
|
filename: appsignal-x86_64-linux-all-dynamic.tar.gz
|
74
74
|
x86_64-linux-musl:
|
75
75
|
static:
|
76
|
-
checksum:
|
76
|
+
checksum: 61a70bb104b7d7cbb9d51a0a5d806346a6c36deb60d1e41351eb61c4813587c1
|
77
77
|
filename: appsignal-x86_64-linux-musl-all-static.tar.gz
|
78
78
|
dynamic:
|
79
|
-
checksum:
|
79
|
+
checksum: cfe38530c1b1c9ab014aca25dd397540f73ca117fe48119a956d864c9d10c1e5
|
80
80
|
filename: appsignal-x86_64-linux-musl-all-dynamic.tar.gz
|
81
81
|
x86_64-freebsd:
|
82
82
|
static:
|
83
|
-
checksum:
|
83
|
+
checksum: 8662a282787b11a6e48dab944afbf1afca91b45ca3147de8cdadb52ef271a43a
|
84
84
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
85
85
|
dynamic:
|
86
|
-
checksum:
|
86
|
+
checksum: 4d8f0aa768aee213fd7ada877e2e86f47fb4c17269cbe54584ff759d480afc10
|
87
87
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
88
88
|
amd64-freebsd:
|
89
89
|
static:
|
90
|
-
checksum:
|
90
|
+
checksum: 8662a282787b11a6e48dab944afbf1afca91b45ca3147de8cdadb52ef271a43a
|
91
91
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
92
92
|
dynamic:
|
93
|
-
checksum:
|
93
|
+
checksum: 4d8f0aa768aee213fd7ada877e2e86f47fb4c17269cbe54584ff759d480afc10
|
94
94
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
data/ext/base.rb
CHANGED
@@ -31,7 +31,7 @@ def report
|
|
31
31
|
},
|
32
32
|
"language" => {
|
33
33
|
"name" => "ruby",
|
34
|
-
"version" => "#{rbconfig["
|
34
|
+
"version" => "#{rbconfig["RUBY_PROGRAM_VERSION"]}-p#{rbconfig["PATCHLEVEL"]}"
|
35
35
|
},
|
36
36
|
"download" => {
|
37
37
|
"checksum" => "unverified",
|
@@ -443,7 +443,7 @@ module Appsignal
|
|
443
443
|
save :os, os
|
444
444
|
puts_value "Operating System", os_label
|
445
445
|
|
446
|
-
language_version = "#{rbconfig["
|
446
|
+
language_version = "#{rbconfig["RUBY_PROGRAM_VERSION"]}-p#{rbconfig["PATCHLEVEL"]}"
|
447
447
|
save :language_version, language_version
|
448
448
|
puts_format "Ruby version", language_version
|
449
449
|
|
@@ -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
@@ -39,7 +39,6 @@ module Appsignal
|
|
39
39
|
],
|
40
40
|
:send_environment_metadata => true,
|
41
41
|
:send_params => true,
|
42
|
-
:skip_session_data => false,
|
43
42
|
:transaction_debug_mode => false
|
44
43
|
}.freeze
|
45
44
|
|
@@ -88,6 +87,7 @@ module Appsignal
|
|
88
87
|
"APPSIGNAL_RUNNING_IN_CONTAINER" => :running_in_container,
|
89
88
|
"APPSIGNAL_SEND_ENVIRONMENT_METADATA" => :send_environment_metadata,
|
90
89
|
"APPSIGNAL_SEND_PARAMS" => :send_params,
|
90
|
+
"APPSIGNAL_SEND_SESSION_DATA" => :send_session_data,
|
91
91
|
"APPSIGNAL_SKIP_SESSION_DATA" => :skip_session_data,
|
92
92
|
"APPSIGNAL_TRANSACTION_DEBUG_MODE" => :transaction_debug_mode,
|
93
93
|
"APPSIGNAL_WORKING_DIRECTORY_PATH" => :working_directory_path,
|
@@ -125,6 +125,7 @@ module Appsignal
|
|
125
125
|
APPSIGNAL_RUNNING_IN_CONTAINER
|
126
126
|
APPSIGNAL_SEND_ENVIRONMENT_METADATA
|
127
127
|
APPSIGNAL_SEND_PARAMS
|
128
|
+
APPSIGNAL_SEND_SESSION_DATA
|
128
129
|
APPSIGNAL_SKIP_SESSION_DATA
|
129
130
|
APPSIGNAL_TRANSACTION_DEBUG_MODE
|
130
131
|
].freeze
|
@@ -169,7 +170,7 @@ module Appsignal
|
|
169
170
|
# @return [Hash]
|
170
171
|
|
171
172
|
attr_reader :root_path, :env, :config_hash, :system_config,
|
172
|
-
:initial_config, :file_config, :env_config
|
173
|
+
:initial_config, :file_config, :env_config, :override_config
|
173
174
|
attr_accessor :logger
|
174
175
|
|
175
176
|
# Initialize a new configuration object for AppSignal.
|
@@ -230,6 +231,11 @@ module Appsignal
|
|
230
231
|
# Load config from environment variables
|
231
232
|
@env_config = load_from_environment
|
232
233
|
merge(env_config)
|
234
|
+
# Load config overrides
|
235
|
+
@override_config = determine_overrides
|
236
|
+
merge(override_config)
|
237
|
+
# Handle deprecated config options
|
238
|
+
maintain_backwards_compatibility
|
233
239
|
# Validate that we have a correct config
|
234
240
|
validate
|
235
241
|
# Track origin of env
|
@@ -374,12 +380,9 @@ module Appsignal
|
|
374
380
|
configurations = YAML.load(ERB.new(IO.read(config_file)).result, **read_options)
|
375
381
|
config_for_this_env = configurations[env]
|
376
382
|
if config_for_this_env
|
377
|
-
config_for_this_env
|
378
|
-
|
379
|
-
|
380
|
-
end
|
381
|
-
|
382
|
-
maintain_backwards_compatibility(config_for_this_env)
|
383
|
+
config_for_this_env.each_with_object({}) do |(key, value), hash|
|
384
|
+
hash[key.to_sym] = value # convert keys to symbols
|
385
|
+
end
|
383
386
|
else
|
384
387
|
logger.error "Not loading from config file: config for '#{env}' not found"
|
385
388
|
nil
|
@@ -394,20 +397,25 @@ module Appsignal
|
|
394
397
|
nil
|
395
398
|
end
|
396
399
|
|
397
|
-
# Maintain backwards compatibility with config
|
398
|
-
# versions of the gem
|
400
|
+
# Maintain backwards compatibility with deprecated config options.
|
399
401
|
#
|
400
|
-
#
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
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.
|
407
|
+
#
|
408
|
+
# Make sure to remove the contents of this method in the next major
|
409
|
+
# version, but the method itself with an empty body can stick around as a
|
410
|
+
# structure for future deprecations.
|
411
|
+
def maintain_backwards_compatibility
|
412
|
+
return unless config_hash.key?(:working_dir_path)
|
413
|
+
|
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
|
411
419
|
end
|
412
420
|
|
413
421
|
def load_from_environment
|
@@ -437,6 +445,31 @@ module Appsignal
|
|
437
445
|
config
|
438
446
|
end
|
439
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
|
+
|
440
473
|
def merge(new_config)
|
441
474
|
new_config.each do |key, value|
|
442
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
|
@@ -476,12 +476,12 @@ module Appsignal
|
|
476
476
|
#
|
477
477
|
# The session data is sanitized by the {Appsignal::Utils::HashSanitizer}.
|
478
478
|
#
|
479
|
-
# @return [nil] if `:
|
479
|
+
# @return [nil] if `:send_session_data` config is set to `false`.
|
480
480
|
# @return [nil] if the {#request} object doesn't respond to `#session`.
|
481
481
|
# @return [nil] if the {#request} session data is `nil`.
|
482
482
|
# @return [Hash<String, Object>]
|
483
483
|
def sanitized_session_data
|
484
|
-
return if Appsignal.config[:
|
484
|
+
return if !Appsignal.config[:send_session_data] ||
|
485
485
|
!request.respond_to?(:session)
|
486
486
|
session = request.session
|
487
487
|
return unless session
|
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
|
@@ -258,7 +258,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
258
258
|
},
|
259
259
|
"language" => {
|
260
260
|
"name" => "ruby",
|
261
|
-
"version" => "#{rbconfig["
|
261
|
+
"version" => "#{rbconfig["RUBY_PROGRAM_VERSION"]}-p#{rbconfig["PATCHLEVEL"]}",
|
262
262
|
"implementation" => jruby ? "jruby" : "ruby"
|
263
263
|
},
|
264
264
|
"download" => {
|
@@ -295,7 +295,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
295
295
|
" Status: success",
|
296
296
|
"Language details",
|
297
297
|
" Implementation: \"#{jruby ? "jruby" : "ruby"}\"",
|
298
|
-
" Ruby version: \"#{"#{rbconfig["
|
298
|
+
" Ruby version: \"#{"#{rbconfig["RUBY_PROGRAM_VERSION"]}-p#{rbconfig["PATCHLEVEL"]}"}\"",
|
299
299
|
"Download details",
|
300
300
|
" Download URL: \"https://",
|
301
301
|
" Checksum: \"verified\"",
|
@@ -604,7 +604,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
604
604
|
|
605
605
|
describe "host information" do
|
606
606
|
let(:rbconfig) { RbConfig::CONFIG }
|
607
|
-
let(:language_version) { "#{rbconfig["
|
607
|
+
let(:language_version) { "#{rbconfig["RUBY_PROGRAM_VERSION"]}-p#{rbconfig["PATCHLEVEL"]}" }
|
608
608
|
|
609
609
|
it "outputs host information" do
|
610
610
|
run
|
@@ -769,13 +769,14 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
769
769
|
it "transmits validation in report" do
|
770
770
|
default_config = hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG)
|
771
771
|
expect(received_report["config"]).to eq(
|
772
|
-
"options" => default_config.merge("env" => ""),
|
772
|
+
"options" => default_config.merge("env" => "", "send_session_data" => true),
|
773
773
|
"sources" => {
|
774
774
|
"default" => default_config,
|
775
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
|
@@ -893,7 +894,8 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
893
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
|
@@ -920,7 +922,8 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
920
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
|
@@ -69,8 +69,8 @@ describe Appsignal::Config do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "sets the push_api_key as loaded through the env_config" do
|
72
|
-
expect(config.env_config).to
|
73
|
-
expect(config.system_config).to
|
72
|
+
expect(config.env_config).to include(:push_api_key => "abc")
|
73
|
+
expect(config.system_config).to include(:active => true)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -82,8 +82,8 @@ describe Appsignal::Config do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it "sets the push_api_key as loaded through the env_config" do
|
85
|
-
expect(config.env_config).to
|
86
|
-
expect(config.system_config).
|
85
|
+
expect(config.env_config).to include(:push_api_key => "")
|
86
|
+
expect(config.system_config).to_not have_key(:active)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -95,8 +95,8 @@ describe Appsignal::Config do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it "sets the push_api_key as loaded through the env_config" do
|
98
|
-
expect(config.env_config).to
|
99
|
-
expect(config.system_config).
|
98
|
+
expect(config.env_config).to include(:push_api_key => " ")
|
99
|
+
expect(config.system_config).to_not have_key(:active)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -119,7 +119,7 @@ describe Appsignal::Config do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
it "sets the log as loaded through the system" do
|
122
|
-
expect(config.system_config).to
|
122
|
+
expect(config.system_config).to include(:log => "stdout")
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -129,7 +129,7 @@ describe Appsignal::Config do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
it "does not set log as loaded through the system" do
|
132
|
-
expect(config.system_config).
|
132
|
+
expect(config.system_config).to_not have_key(:log)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
@@ -177,7 +177,7 @@ describe Appsignal::Config do
|
|
177
177
|
:revision => "v2.5.1",
|
178
178
|
:send_environment_metadata => true,
|
179
179
|
:send_params => true,
|
180
|
-
:
|
180
|
+
:send_session_data => true,
|
181
181
|
:transaction_debug_mode => false
|
182
182
|
)
|
183
183
|
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] }
|
@@ -743,6 +824,54 @@ describe Appsignal::Config do
|
|
743
824
|
end
|
744
825
|
end
|
745
826
|
|
827
|
+
describe "#maintain_backwards_compatibility" do
|
828
|
+
let(:log_stream) { StringIO.new }
|
829
|
+
let(:logger) { test_logger(log_stream) }
|
830
|
+
let(:logs) { log_contents(log_stream) }
|
831
|
+
let(:config) do
|
832
|
+
described_class.new(Dir.pwd, "production", config_options, logger)
|
833
|
+
end
|
834
|
+
|
835
|
+
describe "working_dir_path" do
|
836
|
+
let(:err_stream) { std_stream }
|
837
|
+
let(:stderr) { err_stream.read }
|
838
|
+
let(:deprecation_message) do
|
839
|
+
"The `working_dir_path` option is deprecated, please use " \
|
840
|
+
"`working_directory_path` instead and specify the " \
|
841
|
+
"full path to the working directory"
|
842
|
+
end
|
843
|
+
before do
|
844
|
+
capture_std_streams(std_stream, err_stream) { config }
|
845
|
+
end
|
846
|
+
|
847
|
+
context "when not set" do
|
848
|
+
let(:config_options) { {} }
|
849
|
+
|
850
|
+
it "sets the default working_dir_path value" do
|
851
|
+
expect(config[:working_dir_path]).to be_nil
|
852
|
+
end
|
853
|
+
|
854
|
+
it "does not print a deprecation warning" do
|
855
|
+
expect(stderr).to_not include("appsignal WARNING: #{deprecation_message}")
|
856
|
+
expect(logs).to_not include(deprecation_message)
|
857
|
+
end
|
858
|
+
end
|
859
|
+
|
860
|
+
context "when set" do
|
861
|
+
let(:config_options) { { :working_dir_path => "/tmp/appsignal2" } }
|
862
|
+
|
863
|
+
it "sets the default working_dir_path value" do
|
864
|
+
expect(config[:working_dir_path]).to eq("/tmp/appsignal2")
|
865
|
+
end
|
866
|
+
|
867
|
+
it "does not print a deprecation warning" do
|
868
|
+
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
869
|
+
expect(logs).to include(deprecation_message)
|
870
|
+
end
|
871
|
+
end
|
872
|
+
end
|
873
|
+
end
|
874
|
+
|
746
875
|
describe "#validate" do
|
747
876
|
subject { config.valid? }
|
748
877
|
let(:config) 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
|
|
@@ -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
|
|
@@ -1282,8 +1282,8 @@ describe Appsignal::Transaction do
|
|
1282
1282
|
end
|
1283
1283
|
end
|
1284
1284
|
|
1285
|
-
context "when
|
1286
|
-
before { Appsignal.config[:
|
1285
|
+
context "when not sending session data" do
|
1286
|
+
before { Appsignal.config[:send_session_data] = false }
|
1287
1287
|
|
1288
1288
|
it "does not set any session data on the transaction" do
|
1289
1289
|
expect(subject).to be_nil
|
@@ -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.22
|
5
5
|
platform: java
|
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-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -405,7 +405,6 @@ files:
|
|
405
405
|
- spec/support/matchers/contains_log.rb
|
406
406
|
- spec/support/matchers/have_colorized_text.rb
|
407
407
|
- spec/support/mocks/fake_gc_profiler.rb
|
408
|
-
- spec/support/mocks/mock_extension.rb
|
409
408
|
- spec/support/mocks/mock_probe.rb
|
410
409
|
- spec/support/rails/my_app.rb
|
411
410
|
- spec/support/shared_examples/instrument.rb
|
@@ -419,6 +418,7 @@ homepage: https://github.com/appsignal/appsignal-ruby
|
|
419
418
|
licenses:
|
420
419
|
- MIT
|
421
420
|
metadata:
|
421
|
+
rubygems_mfa_required: 'true'
|
422
422
|
bug_tracker_uri: https://github.com/appsignal/appsignal-ruby/issues
|
423
423
|
changelog_uri: https://github.com/appsignal/appsignal-ruby/blob/main/CHANGELOG.md
|
424
424
|
documentation_uri: https://docs.appsignal.com/ruby/
|
@@ -440,7 +440,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
440
440
|
- !ruby/object:Gem::Version
|
441
441
|
version: '0'
|
442
442
|
requirements: []
|
443
|
-
rubygems_version: 3.3.
|
443
|
+
rubygems_version: 3.3.6
|
444
444
|
signing_key:
|
445
445
|
specification_version: 4
|
446
446
|
summary: Logs performance and exception data from your app to appsignal.com
|
@@ -558,7 +558,6 @@ test_files:
|
|
558
558
|
- spec/support/matchers/contains_log.rb
|
559
559
|
- spec/support/matchers/have_colorized_text.rb
|
560
560
|
- spec/support/mocks/fake_gc_profiler.rb
|
561
|
-
- spec/support/mocks/mock_extension.rb
|
562
561
|
- spec/support/mocks/mock_probe.rb
|
563
562
|
- spec/support/rails/my_app.rb
|
564
563
|
- spec/support/shared_examples/instrument.rb
|