appsignal 3.4.4 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/.semaphore/semaphore.yml +683 -52
- data/CHANGELOG.md +353 -4
- data/README.md +3 -0
- data/Rakefile +4 -2
- data/appsignal.gemspec +1 -1
- data/build_matrix.yml +27 -13
- data/ext/Rakefile +8 -1
- data/ext/agent.rb +27 -27
- data/ext/appsignal_extension.c +0 -24
- data/ext/base.rb +5 -2
- data/gemfiles/dry-monitor.gemfile +5 -0
- data/gemfiles/rails-7.1.gemfile +7 -0
- data/gemfiles/redis-4.gemfile +5 -0
- data/gemfiles/redis-5.gemfile +6 -0
- data/lib/appsignal/auth_check.rb +1 -1
- data/lib/appsignal/cli/diagnose/paths.rb +33 -10
- data/lib/appsignal/cli/diagnose.rb +15 -1
- data/lib/appsignal/config.rb +72 -7
- data/lib/appsignal/demo.rb +1 -1
- data/lib/appsignal/environment.rb +24 -13
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/rom/sql_formatter.rb +18 -0
- data/lib/appsignal/event_formatter/sequel/sql_formatter.rb +1 -1
- data/lib/appsignal/event_formatter.rb +2 -2
- data/lib/appsignal/extension/jruby.rb +4 -17
- data/lib/appsignal/extension.rb +1 -1
- data/lib/appsignal/heartbeat.rb +71 -0
- data/lib/appsignal/helpers/instrumentation.rb +10 -10
- data/lib/appsignal/helpers/metrics.rb +15 -13
- data/lib/appsignal/hooks/active_job.rb +9 -1
- data/lib/appsignal/hooks/active_support_notifications.rb +18 -9
- data/lib/appsignal/hooks/dry_monitor.rb +20 -0
- data/lib/appsignal/hooks/redis.rb +1 -0
- data/lib/appsignal/hooks/redis_client.rb +28 -0
- data/lib/appsignal/hooks.rb +4 -2
- data/lib/appsignal/integrations/active_support_notifications.rb +26 -0
- data/lib/appsignal/integrations/dry_monitor.rb +22 -0
- data/lib/appsignal/integrations/hanami.rb +1 -1
- data/lib/appsignal/integrations/padrino.rb +1 -1
- data/lib/appsignal/integrations/railtie.rb +28 -6
- data/lib/appsignal/integrations/redis_client.rb +20 -0
- data/lib/appsignal/integrations/sidekiq.rb +2 -2
- data/lib/appsignal/integrations/sinatra.rb +1 -1
- data/lib/appsignal/logger.rb +7 -5
- data/lib/appsignal/minutely.rb +4 -4
- data/lib/appsignal/probes/gvl.rb +1 -1
- data/lib/appsignal/probes/helpers.rb +1 -1
- data/lib/appsignal/probes/mri.rb +1 -1
- data/lib/appsignal/probes/sidekiq.rb +10 -8
- data/lib/appsignal/rack/generic_instrumentation.rb +1 -1
- data/lib/appsignal/rack/rails_instrumentation.rb +2 -2
- data/lib/appsignal/rack/sinatra_instrumentation.rb +5 -4
- data/lib/appsignal/rack/streaming_listener.rb +1 -1
- data/lib/appsignal/span.rb +2 -2
- data/lib/appsignal/transaction.rb +69 -14
- data/lib/appsignal/utils/deprecation_message.rb +2 -2
- data/lib/appsignal/utils/hash_sanitizer.rb +21 -9
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +38 -31
- data/lib/puma/plugin/appsignal.rb +1 -1
- data/resources/cacert.pem +321 -159
- data/spec/lib/appsignal/capistrano2_spec.rb +2 -2
- data/spec/lib/appsignal/capistrano3_spec.rb +2 -2
- data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +11 -0
- data/spec/lib/appsignal/cli/diagnose_spec.rb +70 -13
- data/spec/lib/appsignal/config_spec.rb +75 -18
- data/spec/lib/appsignal/environment_spec.rb +3 -3
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +1 -1
- data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +22 -0
- data/spec/lib/appsignal/heartbeat_spec.rb +89 -0
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +6 -0
- data/spec/lib/appsignal/hooks/activejob_spec.rb +26 -1
- data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +104 -0
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +238 -0
- data/spec/lib/appsignal/hooks/redis_spec.rb +98 -76
- data/spec/lib/appsignal/hooks/resque_spec.rb +1 -1
- data/spec/lib/appsignal/hooks_spec.rb +5 -5
- data/spec/lib/appsignal/integrations/railtie_spec.rb +128 -59
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +20 -15
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +2 -2
- data/spec/lib/appsignal/minutely_spec.rb +2 -2
- data/spec/lib/appsignal/probes/sidekiq_spec.rb +29 -6
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +1 -1
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +163 -71
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +1 -0
- data/spec/lib/appsignal/transaction_spec.rb +139 -10
- data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +42 -4
- data/spec/lib/appsignal_spec.rb +63 -61
- data/spec/lib/puma/appsignal_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -7
- data/spec/support/fixtures/projects/valid/config/appsignal.yml +3 -3
- data/spec/support/helpers/config_helpers.rb +6 -2
- data/spec/support/helpers/dependency_helper.rb +13 -1
- data/spec/support/helpers/log_helpers.rb +2 -2
- data/spec/support/helpers/rails_helper.rb +28 -0
- data/spec/support/matchers/have_colorized_text.rb +1 -1
- metadata +19 -5
- data/ext/._appsignal-agent +0 -0
@@ -1,5 +1,7 @@
|
|
1
1
|
describe Appsignal::Utils::HashSanitizer do
|
2
2
|
let(:file) { uploaded_file }
|
3
|
+
let(:some_array) { [1, 2, 3] }
|
4
|
+
let(:some_hash) { { :a => 1, :b => 2 } }
|
3
5
|
let(:params) do
|
4
6
|
{
|
5
7
|
:text => "string",
|
@@ -8,6 +10,10 @@ describe Appsignal::Utils::HashSanitizer do
|
|
8
10
|
:float => 0.0,
|
9
11
|
:bool_true => true,
|
10
12
|
:bool_false => false,
|
13
|
+
# Non-recursive appearances of the same array instance
|
14
|
+
:some_arrays => [some_array, some_array],
|
15
|
+
# Non-recursive appearances of the same hash instance
|
16
|
+
:some_hashes => { :a => some_hash, :b => some_hash },
|
11
17
|
:nil => nil,
|
12
18
|
:int => 1, # Fixnum
|
13
19
|
:int64 => 1 << 64, # Bignum
|
@@ -20,9 +26,20 @@ describe Appsignal::Utils::HashSanitizer do
|
|
20
26
|
{
|
21
27
|
:key => "value",
|
22
28
|
:file => file
|
23
|
-
}
|
24
|
-
|
25
|
-
|
29
|
+
}.tap do |hsh|
|
30
|
+
# Recursive hash-in-hash (should be [:nested_array][3][:recursive_hash])
|
31
|
+
hsh[:recursive_hash] = hsh
|
32
|
+
end
|
33
|
+
].tap do |ary|
|
34
|
+
# Recursive array-in-array (should be [:nested_array][4])
|
35
|
+
ary << ary
|
36
|
+
# Recursive array-in-hash (should be [:nested_array][3][:recursive_array])
|
37
|
+
ary[3][:recursive_array] = ary
|
38
|
+
end
|
39
|
+
}.tap do |hsh|
|
40
|
+
# Recursive hash-in-array (should be [:nested_array][5])
|
41
|
+
hsh[:nested_array] << hsh
|
42
|
+
end
|
26
43
|
}
|
27
44
|
end
|
28
45
|
|
@@ -43,6 +60,9 @@ describe Appsignal::Utils::HashSanitizer do
|
|
43
60
|
expect(subject[:nil]).to be_nil
|
44
61
|
expect(subject[:int]).to eq(1)
|
45
62
|
expect(subject[:int64]).to eq(1 << 64)
|
63
|
+
expect(subject[:some_arrays]).to eq([[1, 2, 3], [1, 2, 3]])
|
64
|
+
expect(subject[:some_hashes]).to eq({ :a => { :a => 1, :b => 2 },
|
65
|
+
:b => { :a => 1, :b => 2 } })
|
46
66
|
end
|
47
67
|
|
48
68
|
it "does not change the original params" do
|
@@ -72,7 +92,7 @@ describe Appsignal::Utils::HashSanitizer do
|
|
72
92
|
expect(subject[2]).to include "::UploadedFile"
|
73
93
|
end
|
74
94
|
|
75
|
-
describe "
|
95
|
+
describe "nested hash" do
|
76
96
|
subject { sanitized_params[:hash][:nested_array][3] }
|
77
97
|
|
78
98
|
it "returns a sanitized Hash" do
|
@@ -82,6 +102,24 @@ describe Appsignal::Utils::HashSanitizer do
|
|
82
102
|
expect(subject[:file]).to be_instance_of String
|
83
103
|
expect(subject[:file]).to include "::UploadedFile"
|
84
104
|
end
|
105
|
+
|
106
|
+
it "replaces a recursive array" do
|
107
|
+
expect(subject[:recursive_array]).to eq("[RECURSIVE VALUE]")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "replaces a recursive hash" do
|
111
|
+
expect(subject[:recursive_hash]).to eq("[RECURSIVE VALUE]")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "nested array" do
|
116
|
+
it "replaces a recursive array" do
|
117
|
+
expect(sanitized_params[:hash][:nested_array][4]).to eq("[RECURSIVE VALUE]")
|
118
|
+
end
|
119
|
+
|
120
|
+
it "replaces a recursive hash" do
|
121
|
+
expect(sanitized_params[:hash][:nested_array][5]).to eq("[RECURSIVE VALUE]")
|
122
|
+
end
|
85
123
|
end
|
86
124
|
end
|
87
125
|
end
|
data/spec/lib/appsignal_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe Appsignal do
|
|
12
12
|
describe ".config=" do
|
13
13
|
it "should set the config" do
|
14
14
|
config = project_fixture_config
|
15
|
-
expect(Appsignal.
|
15
|
+
expect(Appsignal.internal_logger).to_not receive(:level=)
|
16
16
|
|
17
17
|
Appsignal.config = config
|
18
18
|
expect(Appsignal.config).to eq config
|
@@ -22,9 +22,9 @@ describe Appsignal do
|
|
22
22
|
describe ".start" do
|
23
23
|
context "with no config set beforehand" do
|
24
24
|
it "should do nothing when config is not set and there is no valid config in the env" do
|
25
|
-
expect(Appsignal.
|
25
|
+
expect(Appsignal.internal_logger).to receive(:error)
|
26
26
|
.with("Push API key not set after loading config").once
|
27
|
-
expect(Appsignal.
|
27
|
+
expect(Appsignal.internal_logger).to receive(:error)
|
28
28
|
.with("Not starting, no valid config for this environment").once
|
29
29
|
expect(Appsignal::Extension).to_not receive(:start)
|
30
30
|
Appsignal.start
|
@@ -33,7 +33,7 @@ describe Appsignal do
|
|
33
33
|
it "should create a config from the env" do
|
34
34
|
ENV["APPSIGNAL_PUSH_API_KEY"] = "something"
|
35
35
|
expect(Appsignal::Extension).to receive(:start)
|
36
|
-
expect(Appsignal.
|
36
|
+
expect(Appsignal.internal_logger).not_to receive(:error)
|
37
37
|
silence { Appsignal.start }
|
38
38
|
expect(Appsignal.config[:push_api_key]).to eq("something")
|
39
39
|
end
|
@@ -44,7 +44,7 @@ describe Appsignal do
|
|
44
44
|
|
45
45
|
it "should initialize logging" do
|
46
46
|
Appsignal.start
|
47
|
-
expect(Appsignal.
|
47
|
+
expect(Appsignal.internal_logger.level).to eq Logger::INFO
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should start native" do
|
@@ -122,7 +122,7 @@ describe Appsignal do
|
|
122
122
|
|
123
123
|
it "should change the log level" do
|
124
124
|
Appsignal.start
|
125
|
-
expect(Appsignal.
|
125
|
+
expect(Appsignal.internal_logger.level).to eq Logger::DEBUG
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
@@ -152,7 +152,7 @@ describe Appsignal do
|
|
152
152
|
|
153
153
|
describe ".stop" do
|
154
154
|
it "should call stop on the extension" do
|
155
|
-
expect(Appsignal.
|
155
|
+
expect(Appsignal.internal_logger).to receive(:debug).with("Stopping appsignal")
|
156
156
|
expect(Appsignal::Extension).to receive(:stop)
|
157
157
|
Appsignal.stop
|
158
158
|
expect(Appsignal.active?).to be_falsy
|
@@ -160,7 +160,7 @@ describe Appsignal do
|
|
160
160
|
|
161
161
|
context "with context specified" do
|
162
162
|
it "should log the context" do
|
163
|
-
expect(Appsignal.
|
163
|
+
expect(Appsignal.internal_logger).to receive(:debug).with("Stopping appsignal (something)")
|
164
164
|
expect(Appsignal::Extension).to receive(:stop)
|
165
165
|
Appsignal.stop("something")
|
166
166
|
expect(Appsignal.active?).to be_falsy
|
@@ -222,9 +222,9 @@ describe Appsignal do
|
|
222
222
|
Appsignal.config = project_fixture_config("not_active")
|
223
223
|
Appsignal.start
|
224
224
|
Appsignal.start_logger
|
225
|
-
Appsignal.
|
225
|
+
Appsignal.internal_logger = test_logger(log_stream)
|
226
226
|
end
|
227
|
-
after { Appsignal.
|
227
|
+
after { Appsignal.internal_logger = nil }
|
228
228
|
|
229
229
|
it "should do nothing but still yield the block" do
|
230
230
|
expect(Appsignal::Transaction).to_not receive(:create)
|
@@ -258,7 +258,7 @@ describe Appsignal do
|
|
258
258
|
end
|
259
259
|
|
260
260
|
describe ".listen_for_error" do
|
261
|
-
it "does not record
|
261
|
+
it "does not record anything" do
|
262
262
|
error = RuntimeError.new("specific error")
|
263
263
|
expect do
|
264
264
|
Appsignal.listen_for_error do
|
@@ -308,9 +308,9 @@ describe Appsignal do
|
|
308
308
|
Appsignal.config = project_fixture_config
|
309
309
|
Appsignal.start
|
310
310
|
Appsignal.start_logger
|
311
|
-
Appsignal.
|
311
|
+
Appsignal.internal_logger = test_logger(log_stream)
|
312
312
|
end
|
313
|
-
after { Appsignal.
|
313
|
+
after { Appsignal.internal_logger = nil }
|
314
314
|
|
315
315
|
describe ".monitor_transaction" do
|
316
316
|
context "with a successful call" do
|
@@ -545,7 +545,8 @@ describe Appsignal do
|
|
545
545
|
it "should not raise an exception when out of range" do
|
546
546
|
expect(Appsignal::Extension).to receive(:set_gauge).with("key", 10,
|
547
547
|
Appsignal::Extension.data_map_new).and_raise(RangeError)
|
548
|
-
expect(Appsignal.
|
548
|
+
expect(Appsignal.internal_logger).to receive(:warn)
|
549
|
+
.with("Gauge value 10 for key 'key' is too big")
|
549
550
|
expect do
|
550
551
|
Appsignal.set_gauge("key", 10)
|
551
552
|
end.to_not raise_error
|
@@ -553,46 +554,46 @@ describe Appsignal do
|
|
553
554
|
end
|
554
555
|
|
555
556
|
describe ".set_host_gauge" do
|
556
|
-
|
557
|
-
|
558
|
-
|
557
|
+
let(:err_stream) { std_stream }
|
558
|
+
let(:stderr) { err_stream.read }
|
559
|
+
let(:log_stream) { StringIO.new }
|
560
|
+
let(:logs) { log_contents(log_stream) }
|
561
|
+
let(:deprecation_message) do
|
562
|
+
"The `set_host_gauge` method has been deprecated. " \
|
563
|
+
"Calling this method has no effect. " \
|
564
|
+
"Please remove method call in the following file to remove " \
|
565
|
+
"this message."
|
559
566
|
end
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
Appsignal.set_host_gauge(:key, 1)
|
567
|
+
before do
|
568
|
+
Appsignal.internal_logger = test_logger(log_stream)
|
569
|
+
capture_std_streams(std_stream, err_stream) { Appsignal.set_host_gauge("key", 0.1) }
|
564
570
|
end
|
565
571
|
|
566
|
-
it "
|
567
|
-
expect(
|
568
|
-
|
569
|
-
expect(Appsignal.logger).to receive(:warn)
|
570
|
-
.with("Host gauge value 10 for key 'key' is too big")
|
571
|
-
expect do
|
572
|
-
Appsignal.set_host_gauge("key", 10)
|
573
|
-
end.to_not raise_error
|
572
|
+
it "logs a deprecation warning" do
|
573
|
+
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
574
|
+
expect(logs).to include(deprecation_message)
|
574
575
|
end
|
575
576
|
end
|
576
577
|
|
577
578
|
describe ".set_process_gauge" do
|
578
|
-
|
579
|
-
|
580
|
-
|
579
|
+
let(:err_stream) { std_stream }
|
580
|
+
let(:stderr) { err_stream.read }
|
581
|
+
let(:log_stream) { StringIO.new }
|
582
|
+
let(:logs) { log_contents(log_stream) }
|
583
|
+
let(:deprecation_message) do
|
584
|
+
"The `set_process_gauge` method has been deprecated. " \
|
585
|
+
"Calling this method has no effect. " \
|
586
|
+
"Please remove method call in the following file to remove " \
|
587
|
+
"this message."
|
581
588
|
end
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
Appsignal.set_process_gauge(:key, 1)
|
589
|
+
before do
|
590
|
+
Appsignal.internal_logger = test_logger(log_stream)
|
591
|
+
capture_std_streams(std_stream, err_stream) { Appsignal.set_process_gauge("key", 0.1) }
|
586
592
|
end
|
587
593
|
|
588
|
-
it "
|
589
|
-
expect(
|
590
|
-
|
591
|
-
expect(Appsignal.logger).to receive(:warn)
|
592
|
-
.with("Process gauge value 10 for key 'key' is too big")
|
593
|
-
expect do
|
594
|
-
Appsignal.set_process_gauge("key", 10)
|
595
|
-
end.to_not raise_error
|
594
|
+
it "logs a deprecation warning" do
|
595
|
+
expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
|
596
|
+
expect(logs).to include(deprecation_message)
|
596
597
|
end
|
597
598
|
end
|
598
599
|
|
@@ -624,7 +625,7 @@ describe Appsignal do
|
|
624
625
|
it "should not raise an exception when out of range" do
|
625
626
|
expect(Appsignal::Extension).to receive(:increment_counter)
|
626
627
|
.with("key", 10, Appsignal::Extension.data_map_new).and_raise(RangeError)
|
627
|
-
expect(Appsignal.
|
628
|
+
expect(Appsignal.internal_logger).to receive(:warn)
|
628
629
|
.with("Counter value 10 for key 'key' is too big")
|
629
630
|
expect do
|
630
631
|
Appsignal.increment_counter("key", 10)
|
@@ -654,7 +655,7 @@ describe Appsignal do
|
|
654
655
|
it "should not raise an exception when out of range" do
|
655
656
|
expect(Appsignal::Extension).to receive(:add_distribution_value)
|
656
657
|
.with("key", 10, Appsignal::Extension.data_map_new).and_raise(RangeError)
|
657
|
-
expect(Appsignal.
|
658
|
+
expect(Appsignal.internal_logger).to receive(:warn)
|
658
659
|
.with("Distribution value 10 for key 'key' is too big")
|
659
660
|
expect do
|
660
661
|
Appsignal.add_distribution_value("key", 10)
|
@@ -663,8 +664,8 @@ describe Appsignal do
|
|
663
664
|
end
|
664
665
|
end
|
665
666
|
|
666
|
-
describe ".
|
667
|
-
subject { Appsignal.
|
667
|
+
describe ".internal_logger" do
|
668
|
+
subject { Appsignal.internal_logger }
|
668
669
|
|
669
670
|
it { is_expected.to be_a Logger }
|
670
671
|
end
|
@@ -727,7 +728,7 @@ describe Appsignal do
|
|
727
728
|
let(:error) { double }
|
728
729
|
|
729
730
|
it "logs an error message" do
|
730
|
-
expect(Appsignal.
|
731
|
+
expect(Appsignal.internal_logger).to receive(:error).with(
|
731
732
|
"Appsignal.send_error: Cannot send error. " \
|
732
733
|
"The given value is not an exception: #{error.inspect}"
|
733
734
|
)
|
@@ -915,7 +916,7 @@ describe Appsignal do
|
|
915
916
|
let(:error) { Object.new }
|
916
917
|
|
917
918
|
it "logs an error" do
|
918
|
-
expect(Appsignal.
|
919
|
+
expect(Appsignal.internal_logger).to receive(:error).with(
|
919
920
|
"Appsignal.set_error: Cannot set error. " \
|
920
921
|
"The given value is not an exception: #{error.inspect}"
|
921
922
|
)
|
@@ -1128,7 +1129,7 @@ describe Appsignal do
|
|
1128
1129
|
"production",
|
1129
1130
|
:log_path => log_path
|
1130
1131
|
)
|
1131
|
-
Appsignal.
|
1132
|
+
Appsignal.internal_logger.error("Log in memory")
|
1132
1133
|
end
|
1133
1134
|
|
1134
1135
|
context "when the log path is writable" do
|
@@ -1139,9 +1140,9 @@ describe Appsignal do
|
|
1139
1140
|
capture_stdout(out_stream) do
|
1140
1141
|
initialize_config
|
1141
1142
|
Appsignal.start_logger
|
1142
|
-
Appsignal.
|
1143
|
+
Appsignal.internal_logger.error("Log to file")
|
1143
1144
|
end
|
1144
|
-
expect(Appsignal.
|
1145
|
+
expect(Appsignal.internal_logger).to be_a(Appsignal::Utils::IntegrationLogger)
|
1145
1146
|
end
|
1146
1147
|
|
1147
1148
|
it "logs to file" do
|
@@ -1163,8 +1164,8 @@ describe Appsignal do
|
|
1163
1164
|
capture_stdout(out_stream) do
|
1164
1165
|
initialize_config
|
1165
1166
|
Appsignal.start_logger
|
1166
|
-
Appsignal.
|
1167
|
-
expect(Appsignal.
|
1167
|
+
Appsignal.internal_logger.error("Log to not writable log file")
|
1168
|
+
expect(Appsignal.internal_logger).to be_a(Appsignal::Utils::IntegrationLogger)
|
1168
1169
|
end
|
1169
1170
|
end
|
1170
1171
|
|
@@ -1178,8 +1179,9 @@ describe Appsignal do
|
|
1178
1179
|
end
|
1179
1180
|
|
1180
1181
|
it "outputs a warning" do
|
1182
|
+
puts output
|
1181
1183
|
expect(output).to include \
|
1182
|
-
"[WARN] appsignal: Unable to start logger with log path '#{log_file}'.",
|
1184
|
+
"[WARN] appsignal: Unable to start internal logger with log path '#{log_file}'.",
|
1183
1185
|
"[WARN] appsignal: Permission denied"
|
1184
1186
|
end
|
1185
1187
|
end
|
@@ -1193,9 +1195,9 @@ describe Appsignal do
|
|
1193
1195
|
capture_stdout(out_stream) do
|
1194
1196
|
initialize_config
|
1195
1197
|
Appsignal.start_logger
|
1196
|
-
Appsignal.
|
1198
|
+
Appsignal.internal_logger.error("Log to not writable log path")
|
1197
1199
|
end
|
1198
|
-
expect(Appsignal.
|
1200
|
+
expect(Appsignal.internal_logger).to be_a(Appsignal::Utils::IntegrationLogger)
|
1199
1201
|
end
|
1200
1202
|
after do
|
1201
1203
|
FileUtils.chmod 0o755, Appsignal::Config.system_tmp_dir
|
@@ -1222,9 +1224,9 @@ describe Appsignal do
|
|
1222
1224
|
capture_stdout(out_stream) do
|
1223
1225
|
initialize_config
|
1224
1226
|
Appsignal.start_logger
|
1225
|
-
Appsignal.
|
1227
|
+
Appsignal.internal_logger.error("Log to stdout")
|
1226
1228
|
end
|
1227
|
-
expect(Appsignal.
|
1229
|
+
expect(Appsignal.internal_logger).to be_a(Appsignal::Utils::IntegrationLogger)
|
1228
1230
|
end
|
1229
1231
|
around { |example| recognize_as_heroku { example.run } }
|
1230
1232
|
|
@@ -1238,7 +1240,7 @@ describe Appsignal do
|
|
1238
1240
|
end
|
1239
1241
|
|
1240
1242
|
describe "#logger#level" do
|
1241
|
-
subject { Appsignal.
|
1243
|
+
subject { Appsignal.internal_logger.level }
|
1242
1244
|
|
1243
1245
|
context "when there is no config" do
|
1244
1246
|
before do
|
@@ -204,7 +204,7 @@ RSpec.describe "Puma plugin" do
|
|
204
204
|
}
|
205
205
|
end
|
206
206
|
|
207
|
-
it "collects puma stats as
|
207
|
+
it "collects puma stats as gauge metrics with the (summed) worker metrics" do
|
208
208
|
run_plugin(stats_data, appsignal_plugin) do
|
209
209
|
expect(logs).to_not include([:error, kind_of(String)])
|
210
210
|
expect_gauge(:workers, 2, "type" => "count")
|
data/spec/spec_helper.rb
CHANGED
@@ -12,25 +12,25 @@ require "rspec"
|
|
12
12
|
require "timecop"
|
13
13
|
require "webmock/rspec"
|
14
14
|
|
15
|
-
Dir[File.join(APPSIGNAL_SPEC_DIR, "support", "helpers", "*.rb")].each do |f|
|
15
|
+
Dir[File.join(APPSIGNAL_SPEC_DIR, "support", "helpers", "*.rb")].sort.each do |f|
|
16
16
|
require f
|
17
17
|
end
|
18
|
-
Dir[File.join(DirectoryHelper.support_dir, "mocks", "*.rb")].each do |f|
|
18
|
+
Dir[File.join(DirectoryHelper.support_dir, "mocks", "*.rb")].sort.each do |f|
|
19
19
|
require f
|
20
20
|
end
|
21
|
-
Dir[File.join(DirectoryHelper.support_dir, "matchers", "*.rb")].each do |f|
|
21
|
+
Dir[File.join(DirectoryHelper.support_dir, "matchers", "*.rb")].sort.each do |f|
|
22
22
|
require f
|
23
23
|
end
|
24
|
-
Dir[File.join(APPSIGNAL_SPEC_DIR, "support/shared_examples", "*.rb")].each do |f|
|
24
|
+
Dir[File.join(APPSIGNAL_SPEC_DIR, "support/shared_examples", "*.rb")].sort.each do |f|
|
25
25
|
require f
|
26
26
|
end
|
27
27
|
if DependencyHelper.rails_present?
|
28
|
-
Dir[File.join(DirectoryHelper.support_dir, "rails", "*.rb")].each do |f|
|
28
|
+
Dir[File.join(DirectoryHelper.support_dir, "rails", "*.rb")].sort.each do |f|
|
29
29
|
require f
|
30
30
|
end
|
31
31
|
end
|
32
32
|
if DependencyHelper.hanami2_present?
|
33
|
-
Dir[File.join(DirectoryHelper.support_dir, "hanami", "*.rb")].each do |f|
|
33
|
+
Dir[File.join(DirectoryHelper.support_dir, "hanami", "*.rb")].sort.each do |f|
|
34
34
|
require f
|
35
35
|
end
|
36
36
|
end
|
@@ -165,7 +165,7 @@ RSpec.configure do |config|
|
|
165
165
|
config.after :context do
|
166
166
|
FileUtils.rm_f(File.join(project_fixture_path, "log/appsignal.log"))
|
167
167
|
Appsignal.config = nil
|
168
|
-
Appsignal.
|
168
|
+
Appsignal.internal_logger = nil
|
169
169
|
end
|
170
170
|
|
171
171
|
def stop_minutely_probes
|
@@ -5,7 +5,7 @@ default: &defaults
|
|
5
5
|
"HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
|
6
6
|
"HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
|
7
7
|
"CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
|
8
|
-
"REQUEST_METHOD", "
|
8
|
+
"REQUEST_METHOD", "REQUEST_PATH", "SERVER_NAME", "SERVER_PORT",
|
9
9
|
"SERVER_PROTOCOL", "HTTP_USER_AGENT"
|
10
10
|
]
|
11
11
|
enable_minutely_probes: false
|
@@ -33,7 +33,7 @@ old_config:
|
|
33
33
|
"HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
|
34
34
|
"HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
|
35
35
|
"CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
|
36
|
-
"REQUEST_METHOD", "
|
36
|
+
"REQUEST_METHOD", "REQUEST_PATH", "SERVER_NAME", "SERVER_PORT",
|
37
37
|
"SERVER_PROTOCOL", "HTTP_USER_AGENT"
|
38
38
|
]
|
39
39
|
|
@@ -49,7 +49,7 @@ old_config_mixed_with_new_config:
|
|
49
49
|
"HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
|
50
50
|
"HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
|
51
51
|
"CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
|
52
|
-
"REQUEST_METHOD", "
|
52
|
+
"REQUEST_METHOD", "REQUEST_PATH", "SERVER_NAME", "SERVER_PORT",
|
53
53
|
"SERVER_PROTOCOL", "HTTP_USER_AGENT"
|
54
54
|
]
|
55
55
|
|
@@ -5,8 +5,12 @@ module ConfigHelpers
|
|
5
5
|
)
|
6
6
|
end
|
7
7
|
|
8
|
-
def project_fixture_config(
|
9
|
-
|
8
|
+
def project_fixture_config( # rubocop:disable Metrics/ParameterLists
|
9
|
+
env = "production",
|
10
|
+
initial_config = {},
|
11
|
+
logger = Appsignal.internal_logger,
|
12
|
+
config_file = nil
|
13
|
+
)
|
10
14
|
Appsignal::Config.new(
|
11
15
|
project_fixture_path,
|
12
16
|
env,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module DependencyHelper
|
1
|
+
module DependencyHelper # rubocop:disable Metrics/ModuleLength
|
2
2
|
module_function
|
3
3
|
|
4
4
|
def ruby_version
|
@@ -53,6 +53,14 @@ module DependencyHelper
|
|
53
53
|
dependency_present? "resque"
|
54
54
|
end
|
55
55
|
|
56
|
+
def redis_client_present?
|
57
|
+
dependency_present? "redis-client"
|
58
|
+
end
|
59
|
+
|
60
|
+
def hiredis_client_present?
|
61
|
+
dependency_present? "hiredis-client"
|
62
|
+
end
|
63
|
+
|
56
64
|
def redis_present?
|
57
65
|
dependency_present? "redis"
|
58
66
|
end
|
@@ -115,6 +123,10 @@ module DependencyHelper
|
|
115
123
|
dependency_present? "hanami"
|
116
124
|
end
|
117
125
|
|
126
|
+
def dry_monitor_present?
|
127
|
+
dependency_present? "dry-monitor"
|
128
|
+
end
|
129
|
+
|
118
130
|
def hanami2_present?
|
119
131
|
hanami_present? && Gem.loaded_specs["hanami"].version >= Gem::Version.new("2.0")
|
120
132
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module RailsHelper
|
2
|
+
def with_railtie(app)
|
3
|
+
clear_rails_error_reporter! if Rails.respond_to? :error
|
4
|
+
Appsignal::Integrations::Railtie.initialize_appsignal(app)
|
5
|
+
yield
|
6
|
+
ensure
|
7
|
+
clear_rails_error_reporter!
|
8
|
+
end
|
9
|
+
|
10
|
+
def with_rails_error_reporter
|
11
|
+
if Rails.respond_to? :error
|
12
|
+
clear_rails_error_reporter!
|
13
|
+
Appsignal::Integrations::Railtie.initialize_error_reporter
|
14
|
+
end
|
15
|
+
yield
|
16
|
+
ensure
|
17
|
+
clear_rails_error_reporter!
|
18
|
+
end
|
19
|
+
|
20
|
+
def clear_rails_error_reporter!
|
21
|
+
return unless Rails.respond_to? :error
|
22
|
+
|
23
|
+
Rails
|
24
|
+
.error
|
25
|
+
.instance_variable_get(:@subscribers)
|
26
|
+
.reject! { |s| s == Appsignal::Integrations::RailsErrorReporterSubscriber }
|
27
|
+
end
|
28
|
+
end
|
@@ -12,7 +12,7 @@ RSpec::Matchers.define :have_colorized_text do |color, text|
|
|
12
12
|
attr_reader :expected
|
13
13
|
end
|
14
14
|
|
15
|
-
COLOR_TAG_MATCHER_REGEX = /\e\[(\d+)m
|
15
|
+
COLOR_TAG_MATCHER_REGEX = /\e\[(\d+)m/.freeze
|
16
16
|
RSpec::Matchers.define :have_color_markers do
|
17
17
|
match do |actual|
|
18
18
|
actual =~ COLOR_TAG_MATCHER_REGEX
|