appsignal 3.4.16 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82900f113d16dc43d6fb02e6f2dfd0f2f49c3aefef69f7c7e4d1987762f119d9
4
- data.tar.gz: 9e88ecb0449d0ce64b0e9bbe325834542f08016f31519005a65f077dd34c7979
3
+ metadata.gz: fc20e180510d89079b968f752fe4378590ef2edc3c881af7390e4eca883829c3
4
+ data.tar.gz: e475459d746362fe4a1d66ea260596dd376dd78de5ce0c6192784a61afcaa17b
5
5
  SHA512:
6
- metadata.gz: 0c616cd08fc97b3619267546bb35bc3933831a7bf45478283cd4a0510f79e78b735fb4de3ccc0400618f7495aa01c5f2a5177bd39bb12362f7de462b3e75268d
7
- data.tar.gz: 84f42f07b0ca6611326d8f3fd868221432bd81323837d2586be7b4245559ec94881275a3cf2c4b6899881098bffca72e1a82974bdc8b8e7448b4e04b71fbc781
6
+ metadata.gz: e794952ff70e7b8170bb173ee594cfa609a28cc713e04959a3bc97d274e7c547519f54404dfa2a1ac9d71c0ee47cb999bbbc21f19a66e2cef3d39d88f0ac30f7
7
+ data.tar.gz: 62c66a4814ee5663d7db3a1c2c1e844e5024c152425998685c12cd48e52fad3d6a63027457c3f599d2e506ca5b924734d1d48ca7c7d2b348ab80d2d831260ec3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 3.5.0
4
+
5
+ ### Added
6
+
7
+ - [cee1676f](https://github.com/appsignal/appsignal-ruby/commit/cee1676fc5539e380c58e8a824b5c59c3c927119) minor - Nested errors are now supported. The error causes are stored as sample data on the transaction so they can be displayed in the UI.
8
+
3
9
  ## 3.4.16
4
10
 
5
11
  ### Changed
@@ -12,6 +12,7 @@ module Appsignal
12
12
  ALLOWED_TAG_KEY_TYPES = [Symbol, String].freeze
13
13
  ALLOWED_TAG_VALUE_TYPES = [Symbol, String, Integer].freeze
14
14
  BREADCRUMB_LIMIT = 20
15
+ ERROR_CAUSES_LIMIT = 10
15
16
 
16
17
  class << self
17
18
  def create(id, namespace, request, options = {})
@@ -374,6 +375,41 @@ module Appsignal
374
375
  cleaned_error_message(error),
375
376
  backtrace ? Appsignal::Utils::Data.generate(backtrace) : Appsignal::Extension.data_array_new
376
377
  )
378
+
379
+ root_cause_missing = false
380
+
381
+ causes = []
382
+ while error
383
+ error = error.cause
384
+
385
+ break unless error
386
+
387
+ if causes.length >= ERROR_CAUSES_LIMIT
388
+ Appsignal.logger.debug "Appsignal::Transaction#set_error: Error has more " \
389
+ "than #{ERROR_CAUSES_LIMIT} error causes. Only the first #{ERROR_CAUSES_LIMIT} " \
390
+ "will be reported."
391
+ root_cause_missing = true
392
+ break
393
+ end
394
+
395
+ causes << error
396
+ end
397
+
398
+ return if causes.empty?
399
+
400
+ causes_sample_data = causes.map do |e|
401
+ {
402
+ :name => e.class.name,
403
+ :message => cleaned_error_message(e)
404
+ }
405
+ end
406
+
407
+ causes_sample_data.last[:is_root_cause] = false if root_cause_missing
408
+
409
+ set_sample_data(
410
+ "error_causes",
411
+ causes_sample_data
412
+ )
377
413
  end
378
414
  alias_method :add_exception, :set_error
379
415
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.4.16"
4
+ VERSION = "3.5.0"
5
5
  end
@@ -788,6 +788,99 @@ describe Appsignal::Transaction do
788
788
  end
789
789
  end
790
790
 
791
+ context "when the error has no causes" do
792
+ it "should not send the causes information as sample data" do
793
+ expect(transaction.ext).to_not receive(:set_sample_data)
794
+
795
+ transaction.set_error(error)
796
+ end
797
+ end
798
+
799
+ context "when the error has multiple causes" do
800
+ let(:error) do
801
+ e = ExampleStandardError.new("test message")
802
+ e2 = RuntimeError.new("cause message")
803
+ e3 = StandardError.new("cause message 2")
804
+ allow(e).to receive(:backtrace).and_return(["line 1"])
805
+ allow(e).to receive(:cause).and_return(e2)
806
+ allow(e2).to receive(:cause).and_return(e3)
807
+ e
808
+ end
809
+
810
+ it "sends the causes information as sample data" do
811
+ expect(transaction.ext).to receive(:set_error).with(
812
+ "ExampleStandardError",
813
+ "test message",
814
+ Appsignal::Utils::Data.generate(["line 1"])
815
+ )
816
+
817
+ expect(transaction.ext).to receive(:set_sample_data).with(
818
+ "error_causes",
819
+ Appsignal::Utils::Data.generate(
820
+ [
821
+ {
822
+ :name => "RuntimeError",
823
+ :message => "cause message"
824
+ },
825
+ {
826
+ :name => "StandardError",
827
+ :message => "cause message 2"
828
+ }
829
+ ]
830
+ )
831
+ )
832
+
833
+ expect(Appsignal.logger).to_not receive(:debug)
834
+
835
+ transaction.set_error(error)
836
+ end
837
+ end
838
+
839
+ context "when the error has too many causes" do
840
+ let(:error) do
841
+ e = ExampleStandardError.new("root cause error")
842
+
843
+ 11.times do |i|
844
+ next_e = ExampleStandardError.new("wrapper error #{i}")
845
+ allow(next_e).to receive(:cause).and_return(e)
846
+ e = next_e
847
+ end
848
+
849
+ allow(e).to receive(:backtrace).and_return(["line 1"])
850
+ e
851
+ end
852
+
853
+ it "sends only the first causes as sample data" do
854
+ expect(transaction.ext).to receive(:set_error).with(
855
+ "ExampleStandardError",
856
+ "wrapper error 10",
857
+ Appsignal::Utils::Data.generate(["line 1"])
858
+ )
859
+
860
+ expected_error_causes = Array.new(10) do |i|
861
+ {
862
+ :name => "ExampleStandardError",
863
+ :message => "wrapper error #{9 - i}"
864
+ }
865
+ end
866
+
867
+ expected_error_causes.last[:is_root_cause] = false
868
+
869
+ expect(transaction.ext).to receive(:set_sample_data).with(
870
+ "error_causes",
871
+ Appsignal::Utils::Data.generate(expected_error_causes)
872
+ )
873
+
874
+ expect(Appsignal.logger).to receive(:debug).with(
875
+ "Appsignal::Transaction#set_error: Error has more " \
876
+ "than 10 error causes. Only the first 10 " \
877
+ "will be reported."
878
+ )
879
+
880
+ transaction.set_error(error)
881
+ end
882
+ end
883
+
791
884
  context "when error message is nil" do
792
885
  let(:error) do
793
886
  e = ExampleStandardError.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.16
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-12-01 00:00:00.000000000 Z
13
+ date: 2023-12-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack