appsignal 3.0.14-java → 3.0.18-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -3
- data/.semaphore/semaphore.yml +381 -110
- data/CHANGELOG.md +56 -0
- data/appsignal.gemspec +0 -2
- data/build_matrix.yml +40 -23
- data/ext/agent.yml +25 -25
- data/ext/appsignal_extension.c +201 -0
- data/gemfiles/rails-7.0.gemfile +7 -0
- data/lib/appsignal/cli/diagnose.rb +69 -34
- data/lib/appsignal/config.rb +89 -57
- data/lib/appsignal/extension/jruby.rb +147 -0
- data/lib/appsignal/extension.rb +5 -0
- data/lib/appsignal/integrations/sidekiq.rb +5 -1
- data/lib/appsignal/span.rb +92 -0
- data/lib/appsignal/transaction.rb +12 -1
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +4 -10
- data/script/{install_lintje → lint_git} +4 -0
- data/spec/lib/appsignal/cli/diagnose_spec.rb +27 -23
- data/spec/lib/appsignal/config_spec.rb +104 -20
- data/spec/lib/appsignal/event_formatter_spec.rb +2 -2
- data/spec/lib/appsignal/hooks/activejob_spec.rb +34 -6
- data/spec/lib/appsignal/integrations/padrino_spec.rb +8 -2
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +22 -5
- data/spec/lib/appsignal/span_spec.rb +141 -0
- data/spec/lib/appsignal/transaction_spec.rb +25 -0
- data/spec/lib/appsignal/utils/data_spec.rb +0 -2
- data/spec/lib/appsignal/utils/json_spec.rb +0 -2
- data/spec/lib/appsignal_spec.rb +1 -1
- metadata +8 -4
@@ -0,0 +1,92 @@
|
|
1
|
+
module Appsignal
|
2
|
+
class Span
|
3
|
+
def initialize(namespace = nil, ext = nil)
|
4
|
+
@ext = if ext
|
5
|
+
ext
|
6
|
+
else
|
7
|
+
Appsignal::Extension::Span.root(namespace || "")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def child
|
12
|
+
Span.new(nil, @ext.child)
|
13
|
+
end
|
14
|
+
|
15
|
+
def name=(value)
|
16
|
+
@ext.set_name(value)
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_error(error)
|
20
|
+
unless error.is_a?(Exception)
|
21
|
+
Appsignal.logger.error "Appsignal::Span#add_error: Cannot add error. " \
|
22
|
+
"The given value is not an exception: #{error.inspect}"
|
23
|
+
return
|
24
|
+
end
|
25
|
+
return unless error
|
26
|
+
|
27
|
+
backtrace = cleaned_backtrace(error.backtrace)
|
28
|
+
@ext.add_error(
|
29
|
+
error.class.name,
|
30
|
+
error.message.to_s,
|
31
|
+
backtrace ? Appsignal::Utils::Data.generate(backtrace) : Appsignal::Extension.data_array_new
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_sample_data(key, data)
|
36
|
+
return unless key && data && (data.is_a?(Array) || data.is_a?(Hash))
|
37
|
+
@ext.set_sample_data(
|
38
|
+
key.to_s,
|
39
|
+
Appsignal::Utils::Data.generate(data)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def []=(key, value)
|
44
|
+
case value
|
45
|
+
when String
|
46
|
+
@ext.set_attribute_string(key.to_s, value)
|
47
|
+
when Integer
|
48
|
+
begin
|
49
|
+
@ext.set_attribute_int(key.to_s, value)
|
50
|
+
rescue RangeError
|
51
|
+
@ext.set_attribute_string(key.to_s, "bigint:#{value}")
|
52
|
+
end
|
53
|
+
when TrueClass, FalseClass
|
54
|
+
@ext.set_attribute_bool(key.to_s, value)
|
55
|
+
when Float
|
56
|
+
@ext.set_attribute_double(key.to_s, value)
|
57
|
+
else
|
58
|
+
raise TypeError, "value needs to be a string, int, bool or float"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_h
|
63
|
+
json = @ext.to_json
|
64
|
+
return unless json
|
65
|
+
JSON.parse(json)
|
66
|
+
end
|
67
|
+
|
68
|
+
def instrument
|
69
|
+
yield self
|
70
|
+
ensure
|
71
|
+
close
|
72
|
+
end
|
73
|
+
|
74
|
+
def close
|
75
|
+
@ext.close
|
76
|
+
end
|
77
|
+
|
78
|
+
def closed?
|
79
|
+
to_h.nil?
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def cleaned_backtrace(backtrace)
|
85
|
+
if defined?(::Rails) && backtrace
|
86
|
+
::Rails.backtrace_cleaner.clean(backtrace, nil)
|
87
|
+
else
|
88
|
+
backtrace
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -333,7 +333,7 @@ module Appsignal
|
|
333
333
|
backtrace = cleaned_backtrace(error.backtrace)
|
334
334
|
@ext.set_error(
|
335
335
|
error.class.name,
|
336
|
-
error
|
336
|
+
cleaned_error_message(error),
|
337
337
|
backtrace ? Appsignal::Utils::Data.generate(backtrace) : Appsignal::Extension.data_array_new
|
338
338
|
)
|
339
339
|
end
|
@@ -533,6 +533,17 @@ module Appsignal
|
|
533
533
|
end
|
534
534
|
end
|
535
535
|
|
536
|
+
# Clean error messages that are known to potentially contain user data.
|
537
|
+
# Returns an unchanged message otherwise.
|
538
|
+
def cleaned_error_message(error)
|
539
|
+
case error.class.to_s
|
540
|
+
when "PG::UniqueViolation"
|
541
|
+
error.message.to_s.gsub(/\)=\(.*\)/, ")=(?)")
|
542
|
+
else
|
543
|
+
error.message.to_s
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
536
547
|
# Stub that is returned by {Transaction.current} if there is no current
|
537
548
|
# transaction, so that it's still safe to call methods on it if there is no
|
538
549
|
# current transaction.
|
data/lib/appsignal/version.rb
CHANGED
data/lib/appsignal.rb
CHANGED
@@ -116,12 +116,7 @@ module Appsignal
|
|
116
116
|
)
|
117
117
|
|
118
118
|
if config.valid?
|
119
|
-
logger.level =
|
120
|
-
if config[:debug]
|
121
|
-
Logger::DEBUG
|
122
|
-
else
|
123
|
-
Logger::INFO
|
124
|
-
end
|
119
|
+
logger.level = config.log_level
|
125
120
|
if config.active?
|
126
121
|
logger.info "Starting AppSignal #{Appsignal::VERSION} "\
|
127
122
|
"(#{$PROGRAM_NAME}, Ruby #{RUBY_VERSION}, #{RUBY_PLATFORM})"
|
@@ -230,12 +225,11 @@ module Appsignal
|
|
230
225
|
end
|
231
226
|
|
232
227
|
logger.level =
|
233
|
-
if config
|
234
|
-
|
228
|
+
if config
|
229
|
+
config.log_level
|
235
230
|
else
|
236
|
-
|
231
|
+
Appsignal::Config::DEFAULT_LOG_LEVEL
|
237
232
|
end
|
238
|
-
|
239
233
|
logger << @in_memory_log.string if @in_memory_log
|
240
234
|
end
|
241
235
|
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
set -eu
|
4
4
|
|
5
|
+
LINTJE_VERSION="0.6.1"
|
6
|
+
|
5
7
|
mkdir -p $HOME/bin
|
6
8
|
cache_key=v1-lintje-$LINTJE_VERSION
|
7
9
|
cache restore $cache_key
|
@@ -16,3 +18,5 @@ else
|
|
16
18
|
tar -xz --directory $HOME/bin
|
17
19
|
cache store $cache_key $HOME/bin/lintje
|
18
20
|
fi
|
21
|
+
|
22
|
+
$HOME/bin/lintje $SEMAPHORE_GIT_COMMIT_RANGE
|
@@ -115,7 +115,6 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
115
115
|
it "logs to the log file" do
|
116
116
|
run
|
117
117
|
log_contents = File.read(config.log_file_path)
|
118
|
-
p log_contents
|
119
118
|
expect(log_contents).to contains_log :info, "Starting AppSignal diagnose"
|
120
119
|
end
|
121
120
|
|
@@ -192,8 +191,8 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
192
191
|
|
193
192
|
it "outputs version numbers" do
|
194
193
|
expect(output).to include \
|
195
|
-
"Gem version: #{Appsignal::VERSION}",
|
196
|
-
"Agent version: #{Appsignal::Extension.agent_version}"
|
194
|
+
"Gem version: \"#{Appsignal::VERSION}\"",
|
195
|
+
"Agent version: \"#{Appsignal::Extension.agent_version}\""
|
197
196
|
end
|
198
197
|
|
199
198
|
it "transmits version numbers in report" do
|
@@ -295,18 +294,18 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
295
294
|
"Installation result",
|
296
295
|
" Status: success",
|
297
296
|
"Language details",
|
298
|
-
" Implementation: #{jruby ? "jruby" : "ruby"}",
|
299
|
-
" Ruby version: #{"#{rbconfig["ruby_version"]}-p#{rbconfig["PATCHLEVEL"]}"}",
|
297
|
+
" Implementation: \"#{jruby ? "jruby" : "ruby"}\"",
|
298
|
+
" Ruby version: \"#{"#{rbconfig["ruby_version"]}-p#{rbconfig["PATCHLEVEL"]}"}\"",
|
300
299
|
"Download details",
|
301
|
-
" Download URL: https://",
|
302
|
-
" Checksum: verified",
|
300
|
+
" Download URL: \"https://",
|
301
|
+
" Checksum: \"verified\"",
|
303
302
|
"Build details",
|
304
|
-
" Install time: 20",
|
305
|
-
" Architecture: #{Appsignal::System.agent_architecture}",
|
306
|
-
" Target: #{Appsignal::System.agent_platform}",
|
303
|
+
" Install time: \"20",
|
304
|
+
" Architecture: \"#{Appsignal::System.agent_architecture}\"",
|
305
|
+
" Target: \"#{Appsignal::System.agent_platform}\"",
|
307
306
|
" Musl override: false",
|
308
307
|
" Linux ARM override: false",
|
309
|
-
" Library type: #{jruby ? "dynamic" : "static"}",
|
308
|
+
" Library type: \"#{jruby ? "dynamic" : "static"}\"",
|
310
309
|
" Dependencies: {",
|
311
310
|
" Flags: {",
|
312
311
|
"Host details",
|
@@ -611,9 +610,9 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
611
610
|
run
|
612
611
|
expect(output).to include \
|
613
612
|
"Host information",
|
614
|
-
"Architecture: #{rbconfig["host_cpu"]}",
|
615
|
-
"Operating System: #{rbconfig["host_os"]}",
|
616
|
-
"Ruby version: #{language_version}"
|
613
|
+
"Architecture: \"#{rbconfig["host_cpu"]}\"",
|
614
|
+
"Operating System: \"#{rbconfig["host_os"]}\"",
|
615
|
+
"Ruby version: \"#{language_version}\""
|
617
616
|
end
|
618
617
|
|
619
618
|
context "when on Microsoft Windows" do
|
@@ -751,13 +750,13 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
751
750
|
end
|
752
751
|
|
753
752
|
it "outputs a warning that no config is loaded" do
|
754
|
-
expect(output).to include "
|
753
|
+
expect(output).to include "environment: \"\"\n#{warning_message}"
|
755
754
|
expect(output).to_not have_color_markers
|
756
755
|
end
|
757
756
|
|
758
757
|
context "with color", :color => true do
|
759
758
|
it "outputs a warning that no config is loaded in color" do
|
760
|
-
expect(output).to include "
|
759
|
+
expect(output).to include "environment: \"\"\n"
|
761
760
|
expect(output).to have_colorized_text :red, warning_message
|
762
761
|
end
|
763
762
|
end
|
@@ -786,7 +785,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
786
785
|
describe "environment" do
|
787
786
|
it "outputs environment" do
|
788
787
|
run
|
789
|
-
expect(output).to include(%(
|
788
|
+
expect(output).to include(%(environment: "production"))
|
790
789
|
end
|
791
790
|
|
792
791
|
context "when the source is a single source" do
|
@@ -794,7 +793,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
794
793
|
|
795
794
|
it "outputs the label source after the value" do
|
796
795
|
expect(output).to include(
|
797
|
-
%(
|
796
|
+
%(environment: "#{Appsignal.config.env}" (Loaded from: initial)\n)
|
798
797
|
)
|
799
798
|
end
|
800
799
|
end
|
@@ -811,7 +810,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
811
810
|
|
812
811
|
it "outputs a list of sources with their values" do
|
813
812
|
expect(output).to include(
|
814
|
-
%(
|
813
|
+
%( environment: "production"\n) +
|
815
814
|
%( Sources:\n) +
|
816
815
|
%( initial: "development"\n) +
|
817
816
|
%( env: "production"\n)
|
@@ -905,7 +904,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
905
904
|
before { run_within_dir tmp_dir }
|
906
905
|
|
907
906
|
it "outputs environment" do
|
908
|
-
expect(output).to include(%(
|
907
|
+
expect(output).to include(%(environment: "foobar"))
|
909
908
|
end
|
910
909
|
|
911
910
|
it "outputs config defaults" do
|
@@ -1008,7 +1007,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
1008
1007
|
|
1009
1008
|
it "outputs failure with status code" do
|
1010
1009
|
expect(output).to include "Validation",
|
1011
|
-
"Validating Push API key: Failed
|
1010
|
+
"Validating Push API key: Failed to validate: status 500\n" +
|
1012
1011
|
%("Could not confirm authorization: 500")
|
1013
1012
|
end
|
1014
1013
|
|
@@ -1016,14 +1015,19 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
1016
1015
|
it "outputs error in color" do
|
1017
1016
|
expect(output).to include "Validation",
|
1018
1017
|
"Validating Push API key: " +
|
1019
|
-
colorize(
|
1018
|
+
colorize(
|
1019
|
+
"Failed to validate: status 500\n" +
|
1020
|
+
%("Could not confirm authorization: 500"),
|
1021
|
+
:red
|
1022
|
+
)
|
1020
1023
|
end
|
1021
1024
|
end
|
1022
1025
|
|
1023
1026
|
it "transmits validation in report" do
|
1024
1027
|
expect(received_report).to include(
|
1025
1028
|
"validation" => {
|
1026
|
-
"push_api_key" =>
|
1029
|
+
"push_api_key" => "Failed to validate: status 500\n" +
|
1030
|
+
%("Could not confirm authorization: 500")
|
1027
1031
|
}
|
1028
1032
|
)
|
1029
1033
|
end
|
@@ -151,34 +151,34 @@ describe Appsignal::Config do
|
|
151
151
|
|
152
152
|
it "merges with the default config" do
|
153
153
|
expect(config.config_hash).to eq(
|
154
|
+
:active => true,
|
155
|
+
:ca_file_path => File.join(resources_dir, "cacert.pem"),
|
154
156
|
:debug => false,
|
155
|
-
:
|
157
|
+
:dns_servers => [],
|
158
|
+
:enable_allocation_tracking => true,
|
159
|
+
:enable_gc_instrumentation => false,
|
160
|
+
:enable_host_metrics => true,
|
161
|
+
:enable_minutely_probes => true,
|
162
|
+
:enable_statsd => true,
|
163
|
+
:endpoint => "https://push.appsignal.com",
|
164
|
+
:files_world_accessible => true,
|
165
|
+
:filter_parameters => [],
|
166
|
+
:filter_session_data => [],
|
156
167
|
:ignore_actions => [],
|
157
168
|
:ignore_errors => [],
|
158
169
|
:ignore_namespaces => [],
|
159
|
-
:filter_parameters => [],
|
160
|
-
:filter_session_data => [],
|
161
170
|
:instrument_net_http => true,
|
162
171
|
:instrument_redis => true,
|
163
172
|
:instrument_sequel => true,
|
164
|
-
:
|
165
|
-
:send_environment_metadata => true,
|
166
|
-
:send_params => true,
|
167
|
-
:endpoint => "https://push.appsignal.com",
|
168
|
-
:push_api_key => "abc",
|
173
|
+
:log => "file",
|
169
174
|
:name => "TestApp",
|
170
|
-
:
|
171
|
-
:
|
172
|
-
:enable_gc_instrumentation => false,
|
173
|
-
:enable_host_metrics => true,
|
174
|
-
:enable_minutely_probes => true,
|
175
|
-
:enable_statsd => true,
|
176
|
-
:ca_file_path => File.join(resources_dir, "cacert.pem"),
|
177
|
-
:dns_servers => [],
|
178
|
-
:files_world_accessible => true,
|
179
|
-
:transaction_debug_mode => false,
|
175
|
+
:push_api_key => "abc",
|
176
|
+
:request_headers => [],
|
180
177
|
:revision => "v2.5.1",
|
181
|
-
:
|
178
|
+
:send_environment_metadata => true,
|
179
|
+
:send_params => true,
|
180
|
+
:skip_session_data => false,
|
181
|
+
:transaction_debug_mode => false
|
182
182
|
)
|
183
183
|
end
|
184
184
|
|
@@ -319,13 +319,15 @@ describe Appsignal::Config do
|
|
319
319
|
"non-existing-path",
|
320
320
|
"production",
|
321
321
|
:running_in_container => true,
|
322
|
-
:debug => true
|
322
|
+
:debug => true,
|
323
|
+
:log_level => "debug"
|
323
324
|
)
|
324
325
|
end
|
325
326
|
|
326
327
|
it "overrides system detected and defaults config" do
|
327
328
|
expect(config[:running_in_container]).to be_truthy
|
328
329
|
expect(config[:debug]).to be_truthy
|
330
|
+
expect(config[:log_level]).to eq("debug")
|
329
331
|
end
|
330
332
|
end
|
331
333
|
|
@@ -502,6 +504,7 @@ describe Appsignal::Config do
|
|
502
504
|
config[:log] = "stdout"
|
503
505
|
config[:log_path] = "/tmp"
|
504
506
|
config[:filter_parameters] = %w[password confirm_password]
|
507
|
+
config[:filter_session_data] = %w[key1 key2]
|
505
508
|
config[:running_in_container] = false
|
506
509
|
config[:dns_servers] = ["8.8.8.8", "8.8.4.4"]
|
507
510
|
config[:transaction_debug_mode] = true
|
@@ -535,6 +538,8 @@ describe Appsignal::Config do
|
|
535
538
|
expect(ENV["_APPSIGNAL_FILES_WORLD_ACCESSIBLE"]).to eq "true"
|
536
539
|
expect(ENV["_APPSIGNAL_TRANSACTION_DEBUG_MODE"]).to eq "true"
|
537
540
|
expect(ENV["_APPSIGNAL_SEND_ENVIRONMENT_METADATA"]).to eq "false"
|
541
|
+
expect(ENV["_APPSIGNAL_FILTER_PARAMETERS"]).to eq "password,confirm_password"
|
542
|
+
expect(ENV["_APPSIGNAL_FILTER_SESSION_DATA"]).to eq "key1,key2"
|
538
543
|
expect(ENV["_APP_REVISION"]).to eq "v2.5.1"
|
539
544
|
expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIR_PATH")
|
540
545
|
expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIRECTORY_PATH")
|
@@ -781,4 +786,83 @@ describe Appsignal::Config do
|
|
781
786
|
end
|
782
787
|
end
|
783
788
|
end
|
789
|
+
|
790
|
+
describe "#log_level" do
|
791
|
+
let(:options) { {} }
|
792
|
+
let(:config) { described_class.new("", nil, options) }
|
793
|
+
subject { config.log_level }
|
794
|
+
|
795
|
+
context "without any config" do
|
796
|
+
it "returns info by default" do
|
797
|
+
is_expected.to eq(Logger::INFO)
|
798
|
+
end
|
799
|
+
end
|
800
|
+
|
801
|
+
context "with debug set to true" do
|
802
|
+
let(:options) { { :debug => true } }
|
803
|
+
it { is_expected.to eq(Logger::DEBUG) }
|
804
|
+
end
|
805
|
+
|
806
|
+
context "with transaction_debug_mode set to true" do
|
807
|
+
let(:options) { { :transaction_debug_mode => true } }
|
808
|
+
it { is_expected.to eq(Logger::DEBUG) }
|
809
|
+
end
|
810
|
+
|
811
|
+
context "with log_level set to error" do
|
812
|
+
let(:options) { { :log_level => "error" } }
|
813
|
+
it { is_expected.to eq(Logger::ERROR) }
|
814
|
+
end
|
815
|
+
|
816
|
+
context "with log_level set to warn" do
|
817
|
+
let(:options) { { :log_level => "warn" } }
|
818
|
+
it { is_expected.to eq(Logger::WARN) }
|
819
|
+
end
|
820
|
+
|
821
|
+
context "with log_level set to info" do
|
822
|
+
let(:options) { { :log_level => "info" } }
|
823
|
+
it { is_expected.to eq(Logger::INFO) }
|
824
|
+
end
|
825
|
+
|
826
|
+
context "with log_level set to debug" do
|
827
|
+
let(:options) { { :log_level => "debug" } }
|
828
|
+
it { is_expected.to eq(Logger::DEBUG) }
|
829
|
+
end
|
830
|
+
|
831
|
+
context "with log_level set to trace" do
|
832
|
+
let(:options) { { :log_level => "trace" } }
|
833
|
+
it { is_expected.to eq(Logger::DEBUG) }
|
834
|
+
end
|
835
|
+
|
836
|
+
context "with debug and log_level set" do
|
837
|
+
let(:options) { { :log_level => "error", :debug => true } }
|
838
|
+
|
839
|
+
it "the log_level option is leading" do
|
840
|
+
is_expected.to eq(Logger::ERROR)
|
841
|
+
end
|
842
|
+
end
|
843
|
+
|
844
|
+
context "with transaction_debug_mode and log_level set" do
|
845
|
+
let(:options) { { :log_level => "error", :transaction_debug_mode => true } }
|
846
|
+
|
847
|
+
it "the log_level option is leading" do
|
848
|
+
is_expected.to eq(Logger::ERROR)
|
849
|
+
end
|
850
|
+
end
|
851
|
+
|
852
|
+
context "with log level set to an unknown value" do
|
853
|
+
let(:options) { { :log_level => "fatal" } }
|
854
|
+
|
855
|
+
it "prints a warning and doesn't use the log_level" do
|
856
|
+
is_expected.to eql(Logger::INFO)
|
857
|
+
end
|
858
|
+
|
859
|
+
context "with debug option set to true" do
|
860
|
+
let(:options) { { :log_level => "fatal", :debug => true } }
|
861
|
+
|
862
|
+
it "prints a warning and sets it to debug" do
|
863
|
+
is_expected.to eql(Logger::DEBUG)
|
864
|
+
end
|
865
|
+
end
|
866
|
+
end
|
867
|
+
end
|
784
868
|
end
|
@@ -28,7 +28,7 @@ end
|
|
28
28
|
|
29
29
|
class MockDependentFormatter < Appsignal::EventFormatter
|
30
30
|
def initialize
|
31
|
-
|
31
|
+
raise "There is an error"
|
32
32
|
end
|
33
33
|
|
34
34
|
def format(_payload)
|
@@ -72,7 +72,7 @@ describe Appsignal::EventFormatter do
|
|
72
72
|
end
|
73
73
|
expect(klass.registered?("mock.dependent")).to be_falsy
|
74
74
|
expect(logs).to contains_log :error, \
|
75
|
-
"'
|
75
|
+
"'There is an error' " \
|
76
76
|
"when initializing mock.dependent event formatter"
|
77
77
|
end
|
78
78
|
end
|
@@ -64,6 +64,13 @@ if DependencyHelper.active_job_present?
|
|
64
64
|
parameterized_expected_args
|
65
65
|
]
|
66
66
|
end
|
67
|
+
let(:expected_perform_events) do
|
68
|
+
if DependencyHelper.rails_version >= Gem::Version.new("7.0.0")
|
69
|
+
["perform.active_job", "perform_start.active_job"]
|
70
|
+
else
|
71
|
+
["perform_start.active_job", "perform.active_job"]
|
72
|
+
end
|
73
|
+
end
|
67
74
|
before do
|
68
75
|
ActiveJob::Base.queue_adapter = :inline
|
69
76
|
|
@@ -119,7 +126,8 @@ if DependencyHelper.active_job_present?
|
|
119
126
|
events = transaction_hash["events"]
|
120
127
|
.sort_by { |e| e["start"] }
|
121
128
|
.map { |event| event["name"] }
|
122
|
-
|
129
|
+
|
130
|
+
expect(events).to eq(expected_perform_events)
|
123
131
|
end
|
124
132
|
|
125
133
|
context "with custom queue" do
|
@@ -208,7 +216,8 @@ if DependencyHelper.active_job_present?
|
|
208
216
|
events = transaction_hash["events"]
|
209
217
|
.sort_by { |e| e["start"] }
|
210
218
|
.map { |event| event["name"] }
|
211
|
-
|
219
|
+
|
220
|
+
expect(events).to eq(expected_perform_events)
|
212
221
|
end
|
213
222
|
|
214
223
|
if DependencyHelper.rails_version >= Gem::Version.new("5.0.0")
|
@@ -286,7 +295,8 @@ if DependencyHelper.active_job_present?
|
|
286
295
|
.reject { |e| e["name"] == "enqueue.active_job" }
|
287
296
|
.sort_by { |e| e["start"] }
|
288
297
|
.map { |event| event["name"] }
|
289
|
-
|
298
|
+
|
299
|
+
expect(events).to eq(expected_perform_events)
|
290
300
|
end
|
291
301
|
end
|
292
302
|
|
@@ -414,7 +424,7 @@ if DependencyHelper.active_job_present?
|
|
414
424
|
expect(transaction_hash).to include(
|
415
425
|
"action" => "ActionMailerTestJob#welcome",
|
416
426
|
"sample_data" => hash_including(
|
417
|
-
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"],
|
427
|
+
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"] + active_job_args_wrapper,
|
418
428
|
"tags" => {
|
419
429
|
"active_job_id" => kind_of(String),
|
420
430
|
"queue" => "mailers"
|
@@ -433,7 +443,7 @@ if DependencyHelper.active_job_present?
|
|
433
443
|
expect(transaction_hash).to include(
|
434
444
|
"action" => "ActionMailerTestJob#welcome",
|
435
445
|
"sample_data" => hash_including(
|
436
|
-
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"] + method_expected_args,
|
446
|
+
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"] + active_job_args_wrapper(:args => method_expected_args),
|
437
447
|
"tags" => {
|
438
448
|
"active_job_id" => kind_of(String),
|
439
449
|
"queue" => "mailers"
|
@@ -453,7 +463,7 @@ if DependencyHelper.active_job_present?
|
|
453
463
|
expect(transaction_hash).to include(
|
454
464
|
"action" => "ActionMailerTestJob#welcome",
|
455
465
|
"sample_data" => hash_including(
|
456
|
-
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"
|
466
|
+
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"] + active_job_args_wrapper(:params => parameterized_expected_args),
|
457
467
|
"tags" => {
|
458
468
|
"active_job_id" => kind_of(String),
|
459
469
|
"queue" => "mailers"
|
@@ -587,5 +597,23 @@ if DependencyHelper.active_job_present?
|
|
587
597
|
"_aj_symbol_keys"
|
588
598
|
end
|
589
599
|
end
|
600
|
+
|
601
|
+
def active_job_args_wrapper(args: [], params: nil)
|
602
|
+
if DependencyHelper.rails_version >= Gem::Version.new("7.0.0")
|
603
|
+
wrapped_args = {
|
604
|
+
"_aj_ruby2_keywords" => ["args"],
|
605
|
+
"args" => args
|
606
|
+
}
|
607
|
+
|
608
|
+
unless params.nil?
|
609
|
+
wrapped_args["params"] = params
|
610
|
+
wrapped_args["_aj_ruby2_keywords"] = ["params", "args"]
|
611
|
+
end
|
612
|
+
|
613
|
+
[wrapped_args]
|
614
|
+
else
|
615
|
+
params.nil? ? args : args + [params]
|
616
|
+
end
|
617
|
+
end
|
590
618
|
end
|
591
619
|
end
|
@@ -98,7 +98,13 @@ if DependencyHelper.padrino_present?
|
|
98
98
|
RSpec::Matchers.define :match_response do |expected_status, expected_content|
|
99
99
|
match do |response|
|
100
100
|
status, _headers, content = response
|
101
|
-
|
101
|
+
matches_content =
|
102
|
+
if expected_content.is_a?(Regexp)
|
103
|
+
content.join =~ expected_content
|
104
|
+
else
|
105
|
+
content == [expected_content].compact
|
106
|
+
end
|
107
|
+
status == expected_status && matches_content
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
@@ -142,7 +148,7 @@ if DependencyHelper.padrino_present?
|
|
142
148
|
expect_a_transaction_to_be_created
|
143
149
|
# Uses path for action name
|
144
150
|
expect(transaction).to receive(:set_action_if_nil).with("PadrinoTestApp#unknown")
|
145
|
-
expect(response).to match_response(404,
|
151
|
+
expect(response).to match_response(404, %r{^GET /404})
|
146
152
|
end
|
147
153
|
end
|
148
154
|
|
@@ -366,6 +366,16 @@ if DependencyHelper.active_job_present?
|
|
366
366
|
}
|
367
367
|
]
|
368
368
|
end
|
369
|
+
let(:expected_wrapped_args) do
|
370
|
+
if DependencyHelper.rails_version >= Gem::Version.new("7.0.0")
|
371
|
+
[{
|
372
|
+
"_aj_ruby2_keywords" => ["args"],
|
373
|
+
"args" => expected_args
|
374
|
+
}]
|
375
|
+
else
|
376
|
+
expected_args
|
377
|
+
end
|
378
|
+
end
|
369
379
|
let(:expected_tags) do
|
370
380
|
{}.tap do |hash|
|
371
381
|
hash["active_job_id"] = kind_of(String)
|
@@ -374,6 +384,13 @@ if DependencyHelper.active_job_present?
|
|
374
384
|
end
|
375
385
|
end
|
376
386
|
end
|
387
|
+
let(:expected_perform_events) do
|
388
|
+
if DependencyHelper.rails_version >= Gem::Version.new("7.0.0")
|
389
|
+
["perform_job.sidekiq", "perform.active_job", "perform_start.active_job"]
|
390
|
+
else
|
391
|
+
["perform_job.sidekiq", "perform_start.active_job", "perform.active_job"]
|
392
|
+
end
|
393
|
+
end
|
377
394
|
before do
|
378
395
|
start_agent
|
379
396
|
Appsignal.logger = test_logger(log)
|
@@ -434,8 +451,8 @@ if DependencyHelper.active_job_present?
|
|
434
451
|
events = transaction_hash["events"]
|
435
452
|
.sort_by { |e| e["start"] }
|
436
453
|
.map { |event| event["name"] }
|
437
|
-
|
438
|
-
|
454
|
+
|
455
|
+
expect(events).to eq(expected_perform_events)
|
439
456
|
end
|
440
457
|
|
441
458
|
context "with error" do
|
@@ -467,8 +484,8 @@ if DependencyHelper.active_job_present?
|
|
467
484
|
events = transaction_hash["events"]
|
468
485
|
.sort_by { |e| e["start"] }
|
469
486
|
.map { |event| event["name"] }
|
470
|
-
|
471
|
-
|
487
|
+
|
488
|
+
expect(events).to eq(expected_perform_events)
|
472
489
|
end
|
473
490
|
end
|
474
491
|
|
@@ -490,7 +507,7 @@ if DependencyHelper.active_job_present?
|
|
490
507
|
expect(transaction_hash).to include(
|
491
508
|
"action" => "ActionMailerSidekiqTestJob#welcome",
|
492
509
|
"sample_data" => hash_including(
|
493
|
-
"params" => ["ActionMailerSidekiqTestJob", "welcome", "deliver_now"] +
|
510
|
+
"params" => ["ActionMailerSidekiqTestJob", "welcome", "deliver_now"] + expected_wrapped_args
|
494
511
|
)
|
495
512
|
)
|
496
513
|
end
|