appsignal 3.4.16-java → 3.5.0-java

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: 9f4bbbebf35d65f97a75c99730464bb19e90387b1c84558c2d2bcaa195d15986
4
- data.tar.gz: 9e88ecb0449d0ce64b0e9bbe325834542f08016f31519005a65f077dd34c7979
3
+ metadata.gz: e71bed209a83f516ef57254ef883b0a49403d7cfd4a4c6542e2b9405e23761b3
4
+ data.tar.gz: e475459d746362fe4a1d66ea260596dd376dd78de5ce0c6192784a61afcaa17b
5
5
  SHA512:
6
- metadata.gz: 296a3681f8ad3d2eddb404e90448afe88d9dc71825f0aa66ad2f5de0418bca9500020ccf8199489a3aee87d935fc54c7cc29d3cc869dcce16bd1d3ffcbb795df
7
- data.tar.gz: 84f42f07b0ca6611326d8f3fd868221432bd81323837d2586be7b4245559ec94881275a3cf2c4b6899881098bffca72e1a82974bdc8b8e7448b4e04b71fbc781
6
+ metadata.gz: 658c5f1a92e9ada6137ce3119f13ea40ad21b0ee33d3896b115fa35e7a7fa04fc1240b0f55ed3f70146431d77cca10601eb6f21f7127b919171545051b7cb4ae
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: java
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