appsignal 2.5.3 → 2.6.0.beta.1
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 +10 -1
- data/.rubocop_todo.yml +1 -1
- data/.travis.yml +8 -1
- data/CHANGELOG.md +12 -0
- data/appsignal.gemspec +2 -2
- data/benchmark.rake +6 -0
- data/ext/agent.yml +35 -35
- data/ext/appsignal_extension.c +27 -9
- data/lib/appsignal.rb +15 -19
- data/lib/appsignal/auth_check.rb +2 -0
- data/lib/appsignal/capistrano.rb +2 -0
- data/lib/appsignal/cli.rb +2 -0
- data/lib/appsignal/cli/demo.rb +2 -0
- data/lib/appsignal/cli/diagnose.rb +2 -0
- data/lib/appsignal/cli/helpers.rb +2 -0
- data/lib/appsignal/cli/install.rb +15 -1
- data/lib/appsignal/cli/notify_of_deploy.rb +8 -0
- data/lib/appsignal/config.rb +44 -5
- data/lib/appsignal/demo.rb +2 -0
- data/lib/appsignal/event_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/faraday/request_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +2 -0
- data/lib/appsignal/extension.rb +2 -0
- data/lib/appsignal/extension/jruby.rb +15 -13
- data/lib/appsignal/garbage_collection_profiler.rb +2 -0
- data/lib/appsignal/hooks.rb +2 -0
- data/lib/appsignal/hooks/action_cable.rb +2 -0
- data/lib/appsignal/hooks/active_support_notifications.rb +2 -0
- data/lib/appsignal/hooks/celluloid.rb +2 -0
- data/lib/appsignal/hooks/data_mapper.rb +2 -0
- data/lib/appsignal/hooks/delayed_job.rb +2 -0
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +2 -0
- data/lib/appsignal/hooks/net_http.rb +2 -0
- data/lib/appsignal/hooks/passenger.rb +2 -0
- data/lib/appsignal/hooks/puma.rb +2 -0
- data/lib/appsignal/hooks/que.rb +2 -0
- data/lib/appsignal/hooks/rake.rb +2 -0
- data/lib/appsignal/hooks/redis.rb +2 -0
- data/lib/appsignal/hooks/sequel.rb +2 -0
- data/lib/appsignal/hooks/shoryuken.rb +6 -2
- data/lib/appsignal/hooks/sidekiq.rb +4 -2
- data/lib/appsignal/hooks/unicorn.rb +2 -0
- data/lib/appsignal/hooks/webmachine.rb +2 -0
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +2 -0
- data/lib/appsignal/integrations/data_mapper.rb +2 -0
- data/lib/appsignal/integrations/delayed_job_plugin.rb +6 -2
- data/lib/appsignal/integrations/grape.rb +2 -0
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +2 -0
- data/lib/appsignal/integrations/object.rb +2 -0
- data/lib/appsignal/integrations/padrino.rb +3 -4
- data/lib/appsignal/integrations/que.rb +2 -0
- data/lib/appsignal/integrations/railtie.rb +2 -0
- data/lib/appsignal/integrations/rake.rb +2 -0
- data/lib/appsignal/integrations/resque.rb +2 -0
- data/lib/appsignal/integrations/resque_active_job.rb +6 -2
- data/lib/appsignal/integrations/sinatra.rb +2 -0
- data/lib/appsignal/integrations/webmachine.rb +2 -0
- data/lib/appsignal/js_exception_transaction.rb +2 -0
- data/lib/appsignal/marker.rb +2 -0
- data/lib/appsignal/minutely.rb +2 -0
- data/lib/appsignal/rack/generic_instrumentation.rb +2 -0
- data/lib/appsignal/rack/js_exception_catcher.rb +2 -0
- data/lib/appsignal/rack/rails_instrumentation.rb +2 -0
- data/lib/appsignal/rack/sinatra_instrumentation.rb +2 -0
- data/lib/appsignal/rack/streaming_listener.rb +2 -0
- data/lib/appsignal/system.rb +2 -0
- data/lib/appsignal/transaction.rb +13 -10
- data/lib/appsignal/transmitter.rb +2 -0
- data/lib/appsignal/utils.rb +3 -1
- data/lib/appsignal/utils/{params_sanitizer.rb → hash_sanitizer.rb} +12 -11
- data/lib/appsignal/utils/query_params_sanitizer.rb +2 -0
- data/lib/appsignal/version.rb +3 -1
- data/lib/sequel/extensions/appsignal_integration.rb +2 -0
- data/resources/appsignal.yml.erb +5 -0
- data/spec/lib/appsignal/auth_check_spec.rb +11 -2
- data/spec/lib/appsignal/cli/install_spec.rb +33 -0
- data/spec/lib/appsignal/config_spec.rb +76 -18
- data/spec/lib/appsignal/extension_spec.rb +3 -3
- data/spec/lib/appsignal/integrations/padrino_spec.rb +8 -28
- data/spec/lib/appsignal/transaction_spec.rb +63 -30
- data/spec/lib/appsignal/utils/{params_sanitizer_spec.rb → hash_sanitizer_spec.rb} +6 -6
- data/spec/lib/appsignal_spec.rb +180 -158
- data/spec/support/helpers/std_streams_helper.rb +19 -12
- data/spec/support/project_fixture/config/appsignal.yml +21 -0
- metadata +11 -11
data/spec/lib/appsignal_spec.rb
CHANGED
@@ -425,19 +425,26 @@ describe Appsignal do
|
|
425
425
|
end
|
426
426
|
|
427
427
|
describe "custom stats" do
|
428
|
+
let(:tags) { { :foo => "bar" } }
|
429
|
+
|
428
430
|
describe ".set_gauge" do
|
429
431
|
it "should call set_gauge on the extension with a string key and float" do
|
430
|
-
expect(Appsignal::Extension).to receive(:set_gauge).with("key", 0.1)
|
432
|
+
expect(Appsignal::Extension).to receive(:set_gauge).with("key", 0.1, Appsignal::Extension.data_map_new)
|
431
433
|
Appsignal.set_gauge("key", 0.1)
|
432
434
|
end
|
433
435
|
|
436
|
+
it "should call set_gauge with tags" do
|
437
|
+
expect(Appsignal::Extension).to receive(:set_gauge).with("key", 0.1, Appsignal::Utils.data_generate(tags))
|
438
|
+
Appsignal.set_gauge("key", 0.1, tags)
|
439
|
+
end
|
440
|
+
|
434
441
|
it "should call set_gauge on the extension with a symbol key and int" do
|
435
|
-
expect(Appsignal::Extension).to receive(:set_gauge).with("key", 1.0)
|
442
|
+
expect(Appsignal::Extension).to receive(:set_gauge).with("key", 1.0, Appsignal::Extension.data_map_new)
|
436
443
|
Appsignal.set_gauge(:key, 1)
|
437
444
|
end
|
438
445
|
|
439
446
|
it "should not raise an exception when out of range" do
|
440
|
-
expect(Appsignal::Extension).to receive(:set_gauge).with("key", 10).and_raise(RangeError)
|
447
|
+
expect(Appsignal::Extension).to receive(:set_gauge).with("key", 10, Appsignal::Extension.data_map_new).and_raise(RangeError)
|
441
448
|
expect(Appsignal.logger).to receive(:warn).with("Gauge value 10 for key 'key' is too big")
|
442
449
|
expect do
|
443
450
|
Appsignal.set_gauge("key", 10)
|
@@ -487,22 +494,27 @@ describe Appsignal do
|
|
487
494
|
|
488
495
|
describe ".increment_counter" do
|
489
496
|
it "should call increment_counter on the extension with a string key" do
|
490
|
-
expect(Appsignal::Extension).to receive(:increment_counter).with("key", 1)
|
497
|
+
expect(Appsignal::Extension).to receive(:increment_counter).with("key", 1, Appsignal::Extension.data_map_new)
|
491
498
|
Appsignal.increment_counter("key")
|
492
499
|
end
|
493
500
|
|
501
|
+
it "should call increment_counter with tags" do
|
502
|
+
expect(Appsignal::Extension).to receive(:increment_counter).with("key", 1, Appsignal::Utils.data_generate(tags))
|
503
|
+
Appsignal.increment_counter("key", 1, tags)
|
504
|
+
end
|
505
|
+
|
494
506
|
it "should call increment_counter on the extension with a symbol key" do
|
495
|
-
expect(Appsignal::Extension).to receive(:increment_counter).with("key", 1)
|
507
|
+
expect(Appsignal::Extension).to receive(:increment_counter).with("key", 1, Appsignal::Extension.data_map_new)
|
496
508
|
Appsignal.increment_counter(:key)
|
497
509
|
end
|
498
510
|
|
499
511
|
it "should call increment_counter on the extension with a count" do
|
500
|
-
expect(Appsignal::Extension).to receive(:increment_counter).with("key", 5)
|
512
|
+
expect(Appsignal::Extension).to receive(:increment_counter).with("key", 5, Appsignal::Extension.data_map_new)
|
501
513
|
Appsignal.increment_counter("key", 5)
|
502
514
|
end
|
503
515
|
|
504
516
|
it "should not raise an exception when out of range" do
|
505
|
-
expect(Appsignal::Extension).to receive(:increment_counter).with("key", 10).and_raise(RangeError)
|
517
|
+
expect(Appsignal::Extension).to receive(:increment_counter).with("key", 10, Appsignal::Extension.data_map_new).and_raise(RangeError)
|
506
518
|
expect(Appsignal.logger).to receive(:warn).with("Counter value 10 for key 'key' is too big")
|
507
519
|
expect do
|
508
520
|
Appsignal.increment_counter("key", 10)
|
@@ -512,17 +524,22 @@ describe Appsignal do
|
|
512
524
|
|
513
525
|
describe ".add_distribution_value" do
|
514
526
|
it "should call add_distribution_value on the extension with a string key and float" do
|
515
|
-
expect(Appsignal::Extension).to receive(:add_distribution_value).with("key", 0.1)
|
527
|
+
expect(Appsignal::Extension).to receive(:add_distribution_value).with("key", 0.1, Appsignal::Extension.data_map_new)
|
516
528
|
Appsignal.add_distribution_value("key", 0.1)
|
517
529
|
end
|
518
530
|
|
531
|
+
it "should call add_distribution_value with tags" do
|
532
|
+
expect(Appsignal::Extension).to receive(:add_distribution_value).with("key", 0.1, Appsignal::Utils.data_generate(tags))
|
533
|
+
Appsignal.add_distribution_value("key", 0.1, tags)
|
534
|
+
end
|
535
|
+
|
519
536
|
it "should call add_distribution_value on the extension with a symbol key and int" do
|
520
|
-
expect(Appsignal::Extension).to receive(:add_distribution_value).with("key", 1.0)
|
537
|
+
expect(Appsignal::Extension).to receive(:add_distribution_value).with("key", 1.0, Appsignal::Extension.data_map_new)
|
521
538
|
Appsignal.add_distribution_value(:key, 1)
|
522
539
|
end
|
523
540
|
|
524
541
|
it "should not raise an exception when out of range" do
|
525
|
-
expect(Appsignal::Extension).to receive(:add_distribution_value).with("key", 10).and_raise(RangeError)
|
542
|
+
expect(Appsignal::Extension).to receive(:add_distribution_value).with("key", 10, Appsignal::Extension.data_map_new).and_raise(RangeError)
|
526
543
|
expect(Appsignal.logger).to receive(:warn).with("Distribution value 10 for key 'key' is too big")
|
527
544
|
expect do
|
528
545
|
Appsignal.add_distribution_value("key", 10)
|
@@ -537,154 +554,6 @@ describe Appsignal do
|
|
537
554
|
it { is_expected.to be_a Logger }
|
538
555
|
end
|
539
556
|
|
540
|
-
describe ".start_logger" do
|
541
|
-
let(:out_stream) { std_stream }
|
542
|
-
let(:output) { out_stream.read }
|
543
|
-
let(:log_path) { File.join(tmp_dir, "log") }
|
544
|
-
let(:log_file) { File.join(log_path, "appsignal.log") }
|
545
|
-
|
546
|
-
before do
|
547
|
-
FileUtils.mkdir_p(log_path)
|
548
|
-
|
549
|
-
Appsignal.logger.error("Log in memory")
|
550
|
-
Appsignal.config = project_fixture_config(
|
551
|
-
"production",
|
552
|
-
:log_path => log_path
|
553
|
-
)
|
554
|
-
end
|
555
|
-
after { FileUtils.rm_rf(log_path) }
|
556
|
-
|
557
|
-
context "when the log path is writable" do
|
558
|
-
context "when the log file is writable" do
|
559
|
-
let(:log_file_contents) { File.open(log_file).read }
|
560
|
-
|
561
|
-
before do
|
562
|
-
capture_stdout(out_stream) do
|
563
|
-
Appsignal.start_logger
|
564
|
-
Appsignal.logger.error("Log to file")
|
565
|
-
end
|
566
|
-
end
|
567
|
-
|
568
|
-
it "logs to file" do
|
569
|
-
expect(File.exist?(log_file)).to be_truthy
|
570
|
-
expect(log_file_contents).to include "[ERROR] Log to file"
|
571
|
-
expect(output).to be_empty
|
572
|
-
end
|
573
|
-
|
574
|
-
it "amends in memory log to log file" do
|
575
|
-
expect(log_file_contents).to include "[ERROR] appsignal: Log in memory"
|
576
|
-
end
|
577
|
-
end
|
578
|
-
|
579
|
-
context "when the log file is not writable" do
|
580
|
-
before do
|
581
|
-
FileUtils.touch log_file
|
582
|
-
FileUtils.chmod 0o444, log_file
|
583
|
-
|
584
|
-
capture_stdout(out_stream) do
|
585
|
-
Appsignal.start_logger
|
586
|
-
Appsignal.logger.error("Log to not writable log file")
|
587
|
-
end
|
588
|
-
end
|
589
|
-
|
590
|
-
it "logs to stdout" do
|
591
|
-
expect(File.writable?(log_file)).to be_falsy
|
592
|
-
expect(output).to include "[ERROR] appsignal: Log to not writable log file"
|
593
|
-
end
|
594
|
-
|
595
|
-
it "amends in memory log to stdout" do
|
596
|
-
expect(output).to include "[ERROR] appsignal: Log in memory"
|
597
|
-
end
|
598
|
-
|
599
|
-
it "outputs a warning" do
|
600
|
-
expect(output).to include \
|
601
|
-
"[WARN] appsignal: Unable to start logger with log path '#{log_file}'.",
|
602
|
-
"[WARN] appsignal: Permission denied"
|
603
|
-
end
|
604
|
-
end
|
605
|
-
end
|
606
|
-
|
607
|
-
context "when the log path and fallback path are not writable" do
|
608
|
-
before do
|
609
|
-
FileUtils.chmod 0o444, log_path
|
610
|
-
FileUtils.chmod 0o444, Appsignal::Config.system_tmp_dir
|
611
|
-
|
612
|
-
capture_stdout(out_stream) do
|
613
|
-
Appsignal.start_logger
|
614
|
-
Appsignal.logger.error("Log to not writable log path")
|
615
|
-
end
|
616
|
-
end
|
617
|
-
after do
|
618
|
-
FileUtils.chmod 0o755, Appsignal::Config.system_tmp_dir
|
619
|
-
end
|
620
|
-
|
621
|
-
it "logs to stdout" do
|
622
|
-
expect(File.writable?(log_path)).to be_falsy
|
623
|
-
expect(output).to include "[ERROR] appsignal: Log to not writable log path"
|
624
|
-
end
|
625
|
-
|
626
|
-
it "amends in memory log to stdout" do
|
627
|
-
expect(output).to include "[ERROR] appsignal: Log in memory"
|
628
|
-
end
|
629
|
-
|
630
|
-
it "outputs a warning" do
|
631
|
-
expect(output).to include \
|
632
|
-
"appsignal: Unable to log to '#{log_path}' "\
|
633
|
-
"or the '#{Appsignal::Config.system_tmp_dir}' fallback."
|
634
|
-
end
|
635
|
-
end
|
636
|
-
|
637
|
-
context "when on Heroku" do
|
638
|
-
before do
|
639
|
-
capture_stdout(out_stream) do
|
640
|
-
Appsignal.start_logger
|
641
|
-
Appsignal.logger.error("Log to stdout")
|
642
|
-
end
|
643
|
-
end
|
644
|
-
around { |example| recognize_as_heroku { example.run } }
|
645
|
-
|
646
|
-
it "logs to stdout" do
|
647
|
-
expect(output).to include "[ERROR] appsignal: Log to stdout"
|
648
|
-
end
|
649
|
-
|
650
|
-
it "amends in memory log to stdout" do
|
651
|
-
expect(output).to include "[ERROR] appsignal: Log in memory"
|
652
|
-
end
|
653
|
-
end
|
654
|
-
|
655
|
-
describe "#logger#level" do
|
656
|
-
subject { Appsignal.logger.level }
|
657
|
-
|
658
|
-
context "when there is no config" do
|
659
|
-
before do
|
660
|
-
Appsignal.config = nil
|
661
|
-
capture_stdout(out_stream) do
|
662
|
-
Appsignal.start_logger
|
663
|
-
end
|
664
|
-
end
|
665
|
-
|
666
|
-
it "sets the log level to info" do
|
667
|
-
expect(subject).to eq Logger::INFO
|
668
|
-
end
|
669
|
-
end
|
670
|
-
|
671
|
-
context "when there is a config" do
|
672
|
-
context "when log level is configured to debug" do
|
673
|
-
before do
|
674
|
-
Appsignal.config.config_hash[:debug] = true
|
675
|
-
capture_stdout(out_stream) do
|
676
|
-
Appsignal.start_logger
|
677
|
-
end
|
678
|
-
end
|
679
|
-
|
680
|
-
it "sets the log level to debug" do
|
681
|
-
expect(subject).to eq Logger::DEBUG
|
682
|
-
end
|
683
|
-
end
|
684
|
-
end
|
685
|
-
end
|
686
|
-
end
|
687
|
-
|
688
557
|
describe ".log_formatter" do
|
689
558
|
subject { Appsignal.log_formatter.call("Debug", Time.parse("2015-07-08"), nil, "log line") }
|
690
559
|
|
@@ -1046,4 +915,157 @@ describe Appsignal do
|
|
1046
915
|
end
|
1047
916
|
end
|
1048
917
|
end
|
918
|
+
|
919
|
+
describe ".start_logger" do
|
920
|
+
let(:out_stream) { std_stream }
|
921
|
+
let(:output) { out_stream.read }
|
922
|
+
let(:log_path) { File.join(tmp_dir, "log") }
|
923
|
+
let(:log_file) { File.join(log_path, "appsignal.log") }
|
924
|
+
|
925
|
+
before { FileUtils.mkdir_p(log_path) }
|
926
|
+
after { FileUtils.rm_rf(log_path) }
|
927
|
+
|
928
|
+
def initialize_config
|
929
|
+
Appsignal.config = project_fixture_config(
|
930
|
+
"production",
|
931
|
+
:log_path => log_path
|
932
|
+
)
|
933
|
+
Appsignal.logger.error("Log in memory")
|
934
|
+
end
|
935
|
+
|
936
|
+
context "when the log path is writable" do
|
937
|
+
context "when the log file is writable" do
|
938
|
+
let(:log_file_contents) { File.open(log_file).read }
|
939
|
+
|
940
|
+
before do
|
941
|
+
capture_stdout(out_stream) do
|
942
|
+
initialize_config
|
943
|
+
Appsignal.start_logger
|
944
|
+
Appsignal.logger.error("Log to file")
|
945
|
+
end
|
946
|
+
end
|
947
|
+
|
948
|
+
it "logs to file" do
|
949
|
+
expect(File.exist?(log_file)).to be_truthy
|
950
|
+
expect(log_file_contents).to include "[ERROR] Log to file"
|
951
|
+
expect(output).to be_empty
|
952
|
+
end
|
953
|
+
|
954
|
+
it "amends in memory log to log file" do
|
955
|
+
expect(log_file_contents).to include "[ERROR] appsignal: Log in memory"
|
956
|
+
end
|
957
|
+
end
|
958
|
+
|
959
|
+
context "when the log file is not writable" do
|
960
|
+
before do
|
961
|
+
FileUtils.touch log_file
|
962
|
+
FileUtils.chmod 0o444, log_file
|
963
|
+
|
964
|
+
capture_stdout(out_stream) do
|
965
|
+
initialize_config
|
966
|
+
Appsignal.start_logger
|
967
|
+
Appsignal.logger.error("Log to not writable log file")
|
968
|
+
end
|
969
|
+
end
|
970
|
+
|
971
|
+
it "logs to stdout" do
|
972
|
+
expect(File.writable?(log_file)).to be_falsy
|
973
|
+
expect(output).to include "[ERROR] appsignal: Log to not writable log file"
|
974
|
+
end
|
975
|
+
|
976
|
+
it "amends in memory log to stdout" do
|
977
|
+
expect(output).to include "[ERROR] appsignal: Log in memory"
|
978
|
+
end
|
979
|
+
|
980
|
+
it "outputs a warning" do
|
981
|
+
expect(output).to include \
|
982
|
+
"[WARN] appsignal: Unable to start logger with log path '#{log_file}'.",
|
983
|
+
"[WARN] appsignal: Permission denied"
|
984
|
+
end
|
985
|
+
end
|
986
|
+
end
|
987
|
+
|
988
|
+
context "when the log path and fallback path are not writable" do
|
989
|
+
before do
|
990
|
+
FileUtils.chmod 0o444, log_path
|
991
|
+
FileUtils.chmod 0o444, Appsignal::Config.system_tmp_dir
|
992
|
+
|
993
|
+
capture_stdout(out_stream) do
|
994
|
+
initialize_config
|
995
|
+
Appsignal.start_logger
|
996
|
+
Appsignal.logger.error("Log to not writable log path")
|
997
|
+
end
|
998
|
+
end
|
999
|
+
after do
|
1000
|
+
FileUtils.chmod 0o755, Appsignal::Config.system_tmp_dir
|
1001
|
+
end
|
1002
|
+
|
1003
|
+
it "logs to stdout" do
|
1004
|
+
expect(File.writable?(log_path)).to be_falsy
|
1005
|
+
expect(output).to include "[ERROR] appsignal: Log to not writable log path"
|
1006
|
+
end
|
1007
|
+
|
1008
|
+
it "amends in memory log to stdout" do
|
1009
|
+
expect(output).to include "[ERROR] appsignal: Log in memory"
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
it "outputs a warning" do
|
1013
|
+
expect(output).to include \
|
1014
|
+
"appsignal: Unable to log to '#{log_path}' "\
|
1015
|
+
"or the '#{Appsignal::Config.system_tmp_dir}' fallback."
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
context "when on Heroku" do
|
1020
|
+
before do
|
1021
|
+
capture_stdout(out_stream) do
|
1022
|
+
initialize_config
|
1023
|
+
Appsignal.start_logger
|
1024
|
+
Appsignal.logger.error("Log to stdout")
|
1025
|
+
end
|
1026
|
+
end
|
1027
|
+
around { |example| recognize_as_heroku { example.run } }
|
1028
|
+
|
1029
|
+
it "logs to stdout" do
|
1030
|
+
expect(output).to include "[ERROR] appsignal: Log to stdout"
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
it "amends in memory log to stdout" do
|
1034
|
+
expect(output).to include "[ERROR] appsignal: Log in memory"
|
1035
|
+
end
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
describe "#logger#level" do
|
1039
|
+
subject { Appsignal.logger.level }
|
1040
|
+
|
1041
|
+
context "when there is no config" do
|
1042
|
+
before do
|
1043
|
+
Appsignal.config = nil
|
1044
|
+
capture_stdout(out_stream) do
|
1045
|
+
Appsignal.start_logger
|
1046
|
+
end
|
1047
|
+
end
|
1048
|
+
|
1049
|
+
it "sets the log level to info" do
|
1050
|
+
expect(subject).to eq Logger::INFO
|
1051
|
+
end
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
context "when there is a config" do
|
1055
|
+
context "when log level is configured to debug" do
|
1056
|
+
before do
|
1057
|
+
capture_stdout(out_stream) do
|
1058
|
+
initialize_config
|
1059
|
+
Appsignal.config[:debug] = true
|
1060
|
+
Appsignal.start_logger
|
1061
|
+
end
|
1062
|
+
end
|
1063
|
+
|
1064
|
+
it "sets the log level to debug" do
|
1065
|
+
expect(subject).to eq Logger::DEBUG
|
1066
|
+
end
|
1067
|
+
end
|
1068
|
+
end
|
1069
|
+
end
|
1070
|
+
end
|
1049
1071
|
end
|
@@ -49,18 +49,25 @@ module StdStreamsHelper
|
|
49
49
|
stderr.unlink
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
# Silence the STDOUT.
|
53
|
+
#
|
54
|
+
# Ignore the STDOUT and don't print it in the test suite's STDOUT.
|
55
|
+
#
|
56
|
+
# If an error is found the output the output is raised as an error, failing
|
57
|
+
# the spec. Warnings and other AppSignal messages are ignored.
|
58
|
+
#
|
59
|
+
# Usage
|
60
|
+
#
|
61
|
+
# silence { do_something }
|
62
|
+
#
|
63
|
+
# silence { puts "ERROR!" }
|
64
|
+
# # => Error found in silenced output:
|
65
|
+
# # ERROR!
|
66
|
+
def silence(&block)
|
67
|
+
stream = Tempfile.new(SecureRandom.uuid)
|
68
|
+
capture_std_streams(stream, stream, &block)
|
60
69
|
ensure
|
61
|
-
|
62
|
-
|
63
|
-
std_stream.rewind
|
64
|
-
std_stream.unlink
|
70
|
+
output = stream.read
|
71
|
+
raise "Error found in silenced output:\n#{output}" if output =~ /(ERR|Error|error)/
|
65
72
|
end
|
66
73
|
end
|
@@ -1,6 +1,13 @@
|
|
1
1
|
default: &defaults
|
2
2
|
push_api_key: "abc"
|
3
3
|
name: "TestApp"
|
4
|
+
request_headers: [
|
5
|
+
"HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
|
6
|
+
"HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
|
7
|
+
"CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
|
8
|
+
"REQUEST_METHOD", "REQUEST_URI", "SERVER_NAME", "SERVER_PORT",
|
9
|
+
"SERVER_PROTOCOL", "HTTP_USER_AGENT"
|
10
|
+
]
|
4
11
|
|
5
12
|
production:
|
6
13
|
<<: *defaults
|
@@ -21,6 +28,13 @@ old_config:
|
|
21
28
|
active: true
|
22
29
|
ignore_exceptions:
|
23
30
|
- StandardError
|
31
|
+
request_headers: [
|
32
|
+
"HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
|
33
|
+
"HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
|
34
|
+
"CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
|
35
|
+
"REQUEST_METHOD", "REQUEST_URI", "SERVER_NAME", "SERVER_PORT",
|
36
|
+
"SERVER_PROTOCOL", "HTTP_USER_AGENT"
|
37
|
+
]
|
24
38
|
|
25
39
|
old_config_mixed_with_new_config:
|
26
40
|
push_api_key: "ghi"
|
@@ -30,3 +44,10 @@ old_config_mixed_with_new_config:
|
|
30
44
|
- NoMethodError
|
31
45
|
ignore_exceptions:
|
32
46
|
- StandardError
|
47
|
+
request_headers: [
|
48
|
+
"HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
|
49
|
+
"HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
|
50
|
+
"CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
|
51
|
+
"REQUEST_METHOD", "REQUEST_URI", "SERVER_NAME", "SERVER_PORT",
|
52
|
+
"SERVER_PROTOCOL", "HTTP_USER_AGENT"
|
53
|
+
]
|