appsignal 3.0.16-java → 3.0.20-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 +512 -103
- data/CHANGELOG.md +37 -0
- data/appsignal.gemspec +0 -2
- data/build_matrix.yml +44 -16
- data/ext/agent.yml +25 -25
- data/ext/base.rb +3 -2
- data/gemfiles/rails-6.1.gemfile +7 -0
- data/gemfiles/rails-7.0.gemfile +7 -0
- data/lib/appsignal/cli/diagnose/utils.rb +0 -14
- data/lib/appsignal/cli/diagnose.rb +4 -4
- data/lib/appsignal/config.rb +65 -20
- data/lib/appsignal/event_formatter/sequel/sql_formatter.rb +24 -0
- data/lib/appsignal/integrations/sidekiq.rb +5 -1
- data/lib/appsignal/system.rb +0 -4
- data/lib/appsignal/transaction.rb +2 -2
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +4 -10
- data/spec/lib/appsignal/cli/diagnose_spec.rb +11 -11
- data/spec/lib/appsignal/config_spec.rb +208 -10
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +2 -2
- data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +30 -0
- data/spec/lib/appsignal/event_formatter_spec.rb +2 -2
- data/spec/lib/appsignal/hooks/activejob_spec.rb +17 -6
- data/spec/lib/appsignal/hooks/sequel_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/padrino_spec.rb +8 -2
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +23 -5
- data/spec/lib/appsignal/transaction_spec.rb +2 -2
- 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 +2 -3
- data/spec/support/helpers/activejob_helpers.rb +27 -0
- data/spec/support/helpers/dependency_helper.rb +13 -1
- metadata +10 -3
@@ -251,14 +251,14 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
251
251
|
|
252
252
|
it "adds the installation report to the diagnostics report" do
|
253
253
|
run
|
254
|
-
jruby =
|
254
|
+
jruby = Appsignal::System.jruby?
|
255
255
|
expect(received_report["installation"]).to match(
|
256
256
|
"result" => {
|
257
257
|
"status" => "success"
|
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\"",
|
@@ -321,7 +321,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
321
321
|
expect(File).to receive(:read)
|
322
322
|
.with(File.expand_path("../../../../../ext/install.report", __FILE__))
|
323
323
|
.and_return(
|
324
|
-
|
324
|
+
JSON.generate(
|
325
325
|
"result" => {
|
326
326
|
"status" => "error",
|
327
327
|
"error" => "RuntimeError: some error",
|
@@ -384,8 +384,8 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
384
384
|
end
|
385
385
|
end
|
386
386
|
|
387
|
-
context "when report is invalid
|
388
|
-
let(:raw_report) { "
|
387
|
+
context "when report is invalid JSON" do
|
388
|
+
let(:raw_report) { "{}-" }
|
389
389
|
before do
|
390
390
|
allow(File).to receive(:read).and_call_original
|
391
391
|
expect(File).to receive(:read)
|
@@ -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,10 +769,10 @@ 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
|
-
"system" => {},
|
775
|
+
"system" => { "send_session_data" => true },
|
776
776
|
"initial" => { "env" => "" },
|
777
777
|
"file" => {},
|
778
778
|
"env" => {}
|
@@ -890,7 +890,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
890
890
|
"options" => hash_with_string_keys(final_config),
|
891
891
|
"sources" => {
|
892
892
|
"default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
|
893
|
-
"system" => {},
|
893
|
+
"system" => { "send_session_data" => true },
|
894
894
|
"initial" => hash_with_string_keys(config.initial_config.merge(additional_initial_config)),
|
895
895
|
"file" => hash_with_string_keys(config.file_config),
|
896
896
|
"env" => {}
|
@@ -917,7 +917,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
917
917
|
"options" => hash_with_string_keys(config.config_hash).merge("env" => "foobar"),
|
918
918
|
"sources" => {
|
919
919
|
"default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
|
920
|
-
"system" => {},
|
920
|
+
"system" => { "send_session_data" => true },
|
921
921
|
"initial" => hash_with_string_keys(config.initial_config),
|
922
922
|
"file" => hash_with_string_keys(config.file_config),
|
923
923
|
"env" => {}
|
@@ -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
|
@@ -171,14 +171,13 @@ describe Appsignal::Config do
|
|
171
171
|
:instrument_redis => true,
|
172
172
|
:instrument_sequel => true,
|
173
173
|
:log => "file",
|
174
|
-
:log_level => "info",
|
175
174
|
:name => "TestApp",
|
176
175
|
:push_api_key => "abc",
|
177
176
|
:request_headers => [],
|
178
177
|
:revision => "v2.5.1",
|
179
178
|
:send_environment_metadata => true,
|
180
179
|
:send_params => true,
|
181
|
-
:
|
180
|
+
:send_session_data => true,
|
182
181
|
:transaction_debug_mode => false
|
183
182
|
)
|
184
183
|
end
|
@@ -744,6 +743,126 @@ describe Appsignal::Config do
|
|
744
743
|
end
|
745
744
|
end
|
746
745
|
|
746
|
+
describe "#maintain_backwards_compatibility" do
|
747
|
+
let(:log_stream) { StringIO.new }
|
748
|
+
let(:logger) { test_logger(log_stream) }
|
749
|
+
let(:logs) { log_contents(log_stream) }
|
750
|
+
let(:config) do
|
751
|
+
described_class.new(Dir.pwd, "production", config_options, logger)
|
752
|
+
end
|
753
|
+
|
754
|
+
describe "working_dir_path" do
|
755
|
+
let(:err_stream) { std_stream }
|
756
|
+
let(:stderr) { err_stream.read }
|
757
|
+
let(:deprecation_message) do
|
758
|
+
"The `working_dir_path` option is deprecated, please use " \
|
759
|
+
"`working_directory_path` instead and specify the " \
|
760
|
+
"full path to the working directory"
|
761
|
+
end
|
762
|
+
before do
|
763
|
+
capture_std_streams(std_stream, err_stream) { config }
|
764
|
+
end
|
765
|
+
|
766
|
+
context "when not set" do
|
767
|
+
let(:config_options) { {} }
|
768
|
+
|
769
|
+
it "sets the default working_dir_path value" do
|
770
|
+
expect(config[:working_dir_path]).to be_nil
|
771
|
+
end
|
772
|
+
|
773
|
+
it "does not print a deprecation warning" do
|
774
|
+
expect(stderr).to_not include("appsignal WARNING: #{deprecation_message}")
|
775
|
+
expect(logs).to_not include(deprecation_message)
|
776
|
+
end
|
777
|
+
end
|
778
|
+
|
779
|
+
context "when set" do
|
780
|
+
let(:config_options) { { :working_dir_path => "/tmp/appsignal2" } }
|
781
|
+
|
782
|
+
it "sets the default working_dir_path value" do
|
783
|
+
expect(config[:working_dir_path]).to eq("/tmp/appsignal2")
|
784
|
+
end
|
785
|
+
|
786
|
+
it "does not print a deprecation warning" do
|
787
|
+
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
788
|
+
expect(logs).to include(deprecation_message)
|
789
|
+
end
|
790
|
+
end
|
791
|
+
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
|
+
end
|
865
|
+
|
747
866
|
describe "#validate" do
|
748
867
|
subject { config.valid? }
|
749
868
|
let(:config) do
|
@@ -787,4 +906,83 @@ describe Appsignal::Config do
|
|
787
906
|
end
|
788
907
|
end
|
789
908
|
end
|
909
|
+
|
910
|
+
describe "#log_level" do
|
911
|
+
let(:options) { {} }
|
912
|
+
let(:config) { described_class.new("", nil, options) }
|
913
|
+
subject { config.log_level }
|
914
|
+
|
915
|
+
context "without any config" do
|
916
|
+
it "returns info by default" do
|
917
|
+
is_expected.to eq(Logger::INFO)
|
918
|
+
end
|
919
|
+
end
|
920
|
+
|
921
|
+
context "with debug set to true" do
|
922
|
+
let(:options) { { :debug => true } }
|
923
|
+
it { is_expected.to eq(Logger::DEBUG) }
|
924
|
+
end
|
925
|
+
|
926
|
+
context "with transaction_debug_mode set to true" do
|
927
|
+
let(:options) { { :transaction_debug_mode => true } }
|
928
|
+
it { is_expected.to eq(Logger::DEBUG) }
|
929
|
+
end
|
930
|
+
|
931
|
+
context "with log_level set to error" do
|
932
|
+
let(:options) { { :log_level => "error" } }
|
933
|
+
it { is_expected.to eq(Logger::ERROR) }
|
934
|
+
end
|
935
|
+
|
936
|
+
context "with log_level set to warn" do
|
937
|
+
let(:options) { { :log_level => "warn" } }
|
938
|
+
it { is_expected.to eq(Logger::WARN) }
|
939
|
+
end
|
940
|
+
|
941
|
+
context "with log_level set to info" do
|
942
|
+
let(:options) { { :log_level => "info" } }
|
943
|
+
it { is_expected.to eq(Logger::INFO) }
|
944
|
+
end
|
945
|
+
|
946
|
+
context "with log_level set to debug" do
|
947
|
+
let(:options) { { :log_level => "debug" } }
|
948
|
+
it { is_expected.to eq(Logger::DEBUG) }
|
949
|
+
end
|
950
|
+
|
951
|
+
context "with log_level set to trace" do
|
952
|
+
let(:options) { { :log_level => "trace" } }
|
953
|
+
it { is_expected.to eq(Logger::DEBUG) }
|
954
|
+
end
|
955
|
+
|
956
|
+
context "with debug and log_level set" do
|
957
|
+
let(:options) { { :log_level => "error", :debug => true } }
|
958
|
+
|
959
|
+
it "the log_level option is leading" do
|
960
|
+
is_expected.to eq(Logger::ERROR)
|
961
|
+
end
|
962
|
+
end
|
963
|
+
|
964
|
+
context "with transaction_debug_mode and log_level set" do
|
965
|
+
let(:options) { { :log_level => "error", :transaction_debug_mode => true } }
|
966
|
+
|
967
|
+
it "the log_level option is leading" do
|
968
|
+
is_expected.to eq(Logger::ERROR)
|
969
|
+
end
|
970
|
+
end
|
971
|
+
|
972
|
+
context "with log level set to an unknown value" do
|
973
|
+
let(:options) { { :log_level => "fatal" } }
|
974
|
+
|
975
|
+
it "prints a warning and doesn't use the log_level" do
|
976
|
+
is_expected.to eql(Logger::INFO)
|
977
|
+
end
|
978
|
+
|
979
|
+
context "with debug option set to true" do
|
980
|
+
let(:options) { { :log_level => "fatal", :debug => true } }
|
981
|
+
|
982
|
+
it "prints a warning and sets it to debug" do
|
983
|
+
is_expected.to eql(Logger::DEBUG)
|
984
|
+
end
|
985
|
+
end
|
986
|
+
end
|
987
|
+
end
|
790
988
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe Appsignal::EventFormatter::ActiveRecord::
|
2
|
-
let(:klass) {
|
1
|
+
describe Appsignal::EventFormatter::ActiveRecord::SqlFormatter do
|
2
|
+
let(:klass) { described_class }
|
3
3
|
let(:formatter) { klass.new }
|
4
4
|
|
5
5
|
it "should register sql.active_record" do
|
@@ -0,0 +1,30 @@
|
|
1
|
+
describe Appsignal::EventFormatter::Sequel::SqlFormatter do
|
2
|
+
let(:klass) { described_class }
|
3
|
+
let(:formatter) { klass.new }
|
4
|
+
|
5
|
+
it "registers the sql.sequel event formatter" do
|
6
|
+
expect(Appsignal::EventFormatter.registered?("sql.sequel", klass)).to be_truthy
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#format" do
|
10
|
+
before do
|
11
|
+
stub_const(
|
12
|
+
"SequelDatabaseTypeClass",
|
13
|
+
Class.new do
|
14
|
+
def self.to_s
|
15
|
+
"SequelDatabaseTypeClassToString"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
)
|
19
|
+
end
|
20
|
+
let(:payload) do
|
21
|
+
{
|
22
|
+
:name => SequelDatabaseTypeClass,
|
23
|
+
:sql => "SELECT * FROM users"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
subject { formatter.format(payload) }
|
27
|
+
|
28
|
+
it { is_expected.to eq ["SequelDatabaseTypeClassToString", "SELECT * FROM users", 1] }
|
29
|
+
end
|
30
|
+
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
|
@@ -30,6 +30,7 @@ if DependencyHelper.active_job_present?
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe Appsignal::Hooks::ActiveJobHook::ActiveJobClassInstrumentation do
|
33
|
+
include ActiveJobHelpers
|
33
34
|
let(:time) { Time.parse("2001-01-01 10:00:00UTC") }
|
34
35
|
let(:namespace) { Appsignal::Transaction::BACKGROUND_JOB }
|
35
36
|
let(:queue) { "default" }
|
@@ -64,6 +65,13 @@ if DependencyHelper.active_job_present?
|
|
64
65
|
parameterized_expected_args
|
65
66
|
]
|
66
67
|
end
|
68
|
+
let(:expected_perform_events) do
|
69
|
+
if DependencyHelper.rails7_present?
|
70
|
+
["perform.active_job", "perform_start.active_job"]
|
71
|
+
else
|
72
|
+
["perform_start.active_job", "perform.active_job"]
|
73
|
+
end
|
74
|
+
end
|
67
75
|
before do
|
68
76
|
ActiveJob::Base.queue_adapter = :inline
|
69
77
|
|
@@ -119,7 +127,8 @@ if DependencyHelper.active_job_present?
|
|
119
127
|
events = transaction_hash["events"]
|
120
128
|
.sort_by { |e| e["start"] }
|
121
129
|
.map { |event| event["name"] }
|
122
|
-
|
130
|
+
|
131
|
+
expect(events).to eq(expected_perform_events)
|
123
132
|
end
|
124
133
|
|
125
134
|
context "with custom queue" do
|
@@ -208,7 +217,8 @@ if DependencyHelper.active_job_present?
|
|
208
217
|
events = transaction_hash["events"]
|
209
218
|
.sort_by { |e| e["start"] }
|
210
219
|
.map { |event| event["name"] }
|
211
|
-
|
220
|
+
|
221
|
+
expect(events).to eq(expected_perform_events)
|
212
222
|
end
|
213
223
|
|
214
224
|
if DependencyHelper.rails_version >= Gem::Version.new("5.0.0")
|
@@ -286,7 +296,8 @@ if DependencyHelper.active_job_present?
|
|
286
296
|
.reject { |e| e["name"] == "enqueue.active_job" }
|
287
297
|
.sort_by { |e| e["start"] }
|
288
298
|
.map { |event| event["name"] }
|
289
|
-
|
299
|
+
|
300
|
+
expect(events).to eq(expected_perform_events)
|
290
301
|
end
|
291
302
|
end
|
292
303
|
|
@@ -414,7 +425,7 @@ if DependencyHelper.active_job_present?
|
|
414
425
|
expect(transaction_hash).to include(
|
415
426
|
"action" => "ActionMailerTestJob#welcome",
|
416
427
|
"sample_data" => hash_including(
|
417
|
-
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"],
|
428
|
+
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"] + active_job_args_wrapper,
|
418
429
|
"tags" => {
|
419
430
|
"active_job_id" => kind_of(String),
|
420
431
|
"queue" => "mailers"
|
@@ -433,7 +444,7 @@ if DependencyHelper.active_job_present?
|
|
433
444
|
expect(transaction_hash).to include(
|
434
445
|
"action" => "ActionMailerTestJob#welcome",
|
435
446
|
"sample_data" => hash_including(
|
436
|
-
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"] + method_expected_args,
|
447
|
+
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"] + active_job_args_wrapper(:args => method_expected_args),
|
437
448
|
"tags" => {
|
438
449
|
"active_job_id" => kind_of(String),
|
439
450
|
"queue" => "mailers"
|
@@ -453,7 +464,7 @@ if DependencyHelper.active_job_present?
|
|
453
464
|
expect(transaction_hash).to include(
|
454
465
|
"action" => "ActionMailerTestJob#welcome",
|
455
466
|
"sample_data" => hash_including(
|
456
|
-
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"
|
467
|
+
"params" => ["ActionMailerTestJob", "welcome", "deliver_now"] + active_job_args_wrapper(:params => parameterized_expected_args),
|
457
468
|
"tags" => {
|
458
469
|
"active_job_id" => kind_of(String),
|
459
470
|
"queue" => "mailers"
|
@@ -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
|
|
@@ -339,6 +339,7 @@ if DependencyHelper.active_job_present?
|
|
339
339
|
require "sidekiq/testing"
|
340
340
|
|
341
341
|
describe "Sidekiq ActiveJob integration" do
|
342
|
+
include ActiveJobHelpers
|
342
343
|
let(:namespace) { Appsignal::Transaction::BACKGROUND_JOB }
|
343
344
|
let(:time) { Time.parse("2001-01-01 10:00:00UTC") }
|
344
345
|
let(:log) { StringIO.new }
|
@@ -366,6 +367,16 @@ if DependencyHelper.active_job_present?
|
|
366
367
|
}
|
367
368
|
]
|
368
369
|
end
|
370
|
+
let(:expected_wrapped_args) do
|
371
|
+
if (DependencyHelper.rails6_1_present? && DependencyHelper.ruby_3_1_or_newer?) || DependencyHelper.rails7_present?
|
372
|
+
[{
|
373
|
+
"_aj_ruby2_keywords" => ["args"],
|
374
|
+
"args" => expected_args
|
375
|
+
}]
|
376
|
+
else
|
377
|
+
expected_args
|
378
|
+
end
|
379
|
+
end
|
369
380
|
let(:expected_tags) do
|
370
381
|
{}.tap do |hash|
|
371
382
|
hash["active_job_id"] = kind_of(String)
|
@@ -374,6 +385,13 @@ if DependencyHelper.active_job_present?
|
|
374
385
|
end
|
375
386
|
end
|
376
387
|
end
|
388
|
+
let(:expected_perform_events) do
|
389
|
+
if DependencyHelper.rails7_present?
|
390
|
+
["perform_job.sidekiq", "perform.active_job", "perform_start.active_job"]
|
391
|
+
else
|
392
|
+
["perform_job.sidekiq", "perform_start.active_job", "perform.active_job"]
|
393
|
+
end
|
394
|
+
end
|
377
395
|
before do
|
378
396
|
start_agent
|
379
397
|
Appsignal.logger = test_logger(log)
|
@@ -434,8 +452,8 @@ if DependencyHelper.active_job_present?
|
|
434
452
|
events = transaction_hash["events"]
|
435
453
|
.sort_by { |e| e["start"] }
|
436
454
|
.map { |event| event["name"] }
|
437
|
-
|
438
|
-
|
455
|
+
|
456
|
+
expect(events).to eq(expected_perform_events)
|
439
457
|
end
|
440
458
|
|
441
459
|
context "with error" do
|
@@ -467,8 +485,8 @@ if DependencyHelper.active_job_present?
|
|
467
485
|
events = transaction_hash["events"]
|
468
486
|
.sort_by { |e| e["start"] }
|
469
487
|
.map { |event| event["name"] }
|
470
|
-
|
471
|
-
|
488
|
+
|
489
|
+
expect(events).to eq(expected_perform_events)
|
472
490
|
end
|
473
491
|
end
|
474
492
|
|
@@ -490,7 +508,7 @@ if DependencyHelper.active_job_present?
|
|
490
508
|
expect(transaction_hash).to include(
|
491
509
|
"action" => "ActionMailerSidekiqTestJob#welcome",
|
492
510
|
"sample_data" => hash_including(
|
493
|
-
"params" => ["ActionMailerSidekiqTestJob", "welcome", "deliver_now"] +
|
511
|
+
"params" => ["ActionMailerSidekiqTestJob", "welcome", "deliver_now"] + expected_wrapped_args
|
494
512
|
)
|
495
513
|
)
|
496
514
|
end
|
@@ -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
|
data/spec/lib/appsignal_spec.rb
CHANGED
@@ -86,8 +86,7 @@ describe Appsignal do
|
|
86
86
|
expect_environment_metadata("ruby_gc_instrumentation_enabled", "true")
|
87
87
|
end
|
88
88
|
|
89
|
-
unless
|
90
|
-
|
89
|
+
unless DependencyHelper.running_jruby?
|
91
90
|
it "installs the allocation event hook" do
|
92
91
|
expect(Appsignal::Extension).to receive(:install_allocation_event_hook)
|
93
92
|
.and_call_original
|
@@ -1236,7 +1235,7 @@ describe Appsignal do
|
|
1236
1235
|
before do
|
1237
1236
|
capture_stdout(out_stream) do
|
1238
1237
|
initialize_config
|
1239
|
-
Appsignal.config[:
|
1238
|
+
Appsignal.config[:log_level] = "debug"
|
1240
1239
|
Appsignal.start_logger
|
1241
1240
|
end
|
1242
1241
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActiveJobHelpers
|
2
|
+
def active_job_args_wrapper(args: [], params: nil)
|
3
|
+
if (DependencyHelper.rails6_1_present? && DependencyHelper.ruby_3_1_or_newer?) || DependencyHelper.rails7_present?
|
4
|
+
wrapped_args = {}
|
5
|
+
|
6
|
+
if params
|
7
|
+
if DependencyHelper.rails7_present?
|
8
|
+
wrapped_args["_aj_ruby2_keywords"] = ["params", "args"]
|
9
|
+
wrapped_args["args"] = []
|
10
|
+
wrapped_args["params"] = {
|
11
|
+
"_aj_symbol_keys" => ["foo"]
|
12
|
+
}.merge(params)
|
13
|
+
else
|
14
|
+
wrapped_args["_aj_symbol_keys"] = ["foo"]
|
15
|
+
wrapped_args.merge!(params)
|
16
|
+
end
|
17
|
+
else
|
18
|
+
wrapped_args["_aj_ruby2_keywords"] = ["args"]
|
19
|
+
wrapped_args["args"] = args
|
20
|
+
end
|
21
|
+
|
22
|
+
[wrapped_args]
|
23
|
+
else
|
24
|
+
params.nil? ? args : args + [params]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|