appsignal 3.0.2-java → 3.0.6-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.semaphore/semaphore.yml +64 -199
  3. data/CHANGELOG.md +42 -18
  4. data/Rakefile +12 -4
  5. data/appsignal.gemspec +19 -4
  6. data/build_matrix.yml +16 -24
  7. data/ext/agent.yml +17 -17
  8. data/ext/base.rb +12 -1
  9. data/gemfiles/capistrano2.gemfile +0 -1
  10. data/gemfiles/capistrano3.gemfile +0 -1
  11. data/gemfiles/grape.gemfile +0 -1
  12. data/gemfiles/no_dependencies.gemfile +2 -6
  13. data/gemfiles/rails-3.2.gemfile +2 -0
  14. data/gemfiles/rails-4.2.gemfile +6 -0
  15. data/gemfiles/resque-2.gemfile +0 -4
  16. data/gemfiles/sequel-435.gemfile +0 -1
  17. data/gemfiles/sequel.gemfile +0 -1
  18. data/gemfiles/sinatra.gemfile +0 -1
  19. data/lib/appsignal/extension.rb +50 -0
  20. data/lib/appsignal/helpers/instrumentation.rb +2 -2
  21. data/lib/appsignal/hooks.rb +2 -1
  22. data/lib/appsignal/hooks/excon.rb +19 -0
  23. data/lib/appsignal/integrations/excon.rb +20 -0
  24. data/lib/appsignal/integrations/padrino.rb +1 -1
  25. data/lib/appsignal/integrations/railtie.rb +1 -1
  26. data/lib/appsignal/integrations/redis.rb +8 -5
  27. data/lib/appsignal/integrations/sinatra.rb +1 -1
  28. data/lib/appsignal/transaction.rb +2 -2
  29. data/lib/appsignal/version.rb +1 -1
  30. data/mono.yml +16 -0
  31. data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -0
  32. data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -7
  33. data/spec/lib/appsignal/extension_spec.rb +43 -9
  34. data/spec/lib/appsignal/hooks/excon_spec.rb +74 -0
  35. data/spec/lib/appsignal/hooks/redis_spec.rb +34 -10
  36. data/spec/lib/appsignal/hooks_spec.rb +4 -1
  37. data/spec/lib/appsignal/transaction_spec.rb +17 -0
  38. data/spec/lib/appsignal/utils/data_spec.rb +133 -87
  39. data/spec/lib/appsignal_spec.rb +2 -2
  40. data/spec/lib/puma/appsignal_spec.rb +1 -1
  41. data/spec/spec_helper.rb +22 -0
  42. data/spec/support/testing.rb +11 -1
  43. data/support/install_deps +9 -8
  44. metadata +8 -5
  45. data/gemfiles/rails-4.0.gemfile +0 -6
  46. data/gemfiles/rails-4.1.gemfile +0 -6
@@ -68,7 +68,10 @@ describe Appsignal::Hooks do
68
68
  expect(Appsignal::Hooks.hooks[:mock_error_hook].installed?).to be_falsy
69
69
 
70
70
  expect(Appsignal.logger).to receive(:error).with("Error while installing mock_error_hook hook: error").once
71
- expect(Appsignal.logger).to receive(:debug).once do |message|
71
+ expect(Appsignal.logger).to receive(:debug).ordered do |message|
72
+ expect(message).to eq("Installing mock_error_hook hook")
73
+ end
74
+ expect(Appsignal.logger).to receive(:debug).ordered do |message|
72
75
  # Start of the error backtrace as debug log
73
76
  expect(message).to start_with(File.expand_path("../../../../", __FILE__))
74
77
  end
@@ -246,6 +246,23 @@ describe Appsignal::Transaction do
246
246
  expect(transaction.ext).to_not be_nil
247
247
  end
248
248
 
249
+ context "when extension is not loaded", :extension_installation_failure do
250
+ around do |example|
251
+ Appsignal::Testing.without_testing { example.run }
252
+ end
253
+
254
+ it "does not error on missing extension method calls" do
255
+ expect(transaction.ext).to be_kind_of(Appsignal::Extension::MockTransaction)
256
+ transaction.start_event
257
+ transaction.finish_event(
258
+ "name",
259
+ "title",
260
+ "body",
261
+ Appsignal::EventFormatter::DEFAULT
262
+ )
263
+ end
264
+ end
265
+
249
266
  it "sets the transaction id" do
250
267
  expect(transaction.transaction_id).to eq "1"
251
268
  end
@@ -4,110 +4,156 @@ describe Appsignal::Utils::Data do
4
4
  describe ".generate" do
5
5
  subject { Appsignal::Utils::Data.generate(body) }
6
6
 
7
- context "with a valid hash body" do
8
- let(:body) do
9
- {
10
- "the" => "payload",
11
- "int" => 1, # Fixnum
12
- "int61" => 1 << 61, # Fixnum
13
- "int62" => 1 << 62, # Bignum, this one still works
14
- "int63" => 1 << 63, # Bignum, turnover point for C, too big for long
15
- "int64" => 1 << 64, # Bignum
16
- "float" => 1.0,
17
- 1 => true,
18
- nil => "test",
19
- :foo => [1, 2, "three", { "foo" => "bar" }],
20
- "bar" => nil,
21
- "baz" => { "foo" => "bʊr", "arr" => [1, 2] }
22
- }
7
+ context "when extension is not loaded", :extension_installation_failure do
8
+ around do |example|
9
+ Appsignal::Testing.without_testing { example.run }
23
10
  end
24
11
 
25
- it { is_expected.to eq Appsignal::Utils::Data.generate(body) }
26
- it { is_expected.to_not eq Appsignal::Utils::Data.generate({}) }
27
-
28
- describe "#to_s" do
29
- it "returns a serialized hash" do
30
- expect(subject.to_s).to eq %({"":"test",) +
31
- %("1":true,) +
32
- %("bar":null,) +
33
- %("baz":{"arr":[1,2],"foo":"bʊr"},) +
34
- %("float":1.0,) +
35
- %("foo":[1,2,"three",{"foo":"bar"}],) +
36
- %("int":1,) +
37
- %("int61":#{1 << 61},) +
38
- %("int62":#{1 << 62},) +
39
- %("int63":"bigint:#{1 << 63}",) +
40
- %("int64":"bigint:#{1 << 64}",) +
41
- %("the":"payload"})
12
+ context "with valid hash body" do
13
+ let(:body) { hash_body }
14
+
15
+ it "does not error and returns MockData class" do
16
+ expect(subject).to be_kind_of(Appsignal::Extension::MockData)
17
+ expect(subject.to_s).to eql("{}")
42
18
  end
43
19
  end
44
- end
45
20
 
46
- context "with a valid array body" do
47
- let(:body) do
48
- [
49
- nil,
50
- true,
51
- false,
52
- "string",
53
- 1, # Fixnum
54
- 1.0, # Float
55
- 1 << 61, # Fixnum
56
- 1 << 62, # Bignum, this one still works
57
- 1 << 63, # Bignum, turnover point for C, too big for long
58
- 1 << 64, # Bignum
59
- { "arr" => [1, 2, "three"], "foo" => "bʊr" }
60
- ]
21
+ context "with valid array body" do
22
+ let(:body) { array_body }
23
+
24
+ it "does not error and returns MockData class" do
25
+ expect(subject).to be_kind_of(Appsignal::Extension::MockData)
26
+ expect(subject.to_s).to eql("{}")
27
+ end
61
28
  end
62
29
 
63
- it { is_expected.to eq Appsignal::Utils::Data.generate(body) }
64
- it { is_expected.to_not eq Appsignal::Utils::Data.generate({}) }
65
-
66
- describe "#to_s" do
67
- it "returns a serialized array" do
68
- expect(subject.to_s).to eq %([null,) +
69
- %(true,) +
70
- %(false,) +
71
- %(\"string\",) +
72
- %(1,) +
73
- %(1.0,) +
74
- %(#{1 << 61},) +
75
- %(#{1 << 62},) +
76
- %("bigint:#{1 << 63}",) +
77
- %("bigint:#{1 << 64}",) +
78
- %({\"arr\":[1,2,\"three\"],\"foo\":\"bʊr\"}])
30
+ context "with an invalid body" do
31
+ let(:body) { "body" }
32
+
33
+ it "raise a type error" do
34
+ expect do
35
+ subject
36
+ end.to raise_error TypeError
79
37
  end
80
38
  end
81
39
  end
82
40
 
83
- context "with a body that contains strings with invalid utf-8 content" do
84
- let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack("c*") }
85
- let(:body) do
86
- {
87
- "field_one" => [0x61, 0x61].pack("c*"),
88
- :field_two => string_with_invalid_utf8,
89
- "field_three" => [
90
- "one", string_with_invalid_utf8
91
- ],
92
- "field_four" => {
93
- "one" => string_with_invalid_utf8
94
- }
95
- }
41
+ context "when extension is loaded" do
42
+ context "with a valid hash body" do
43
+ let(:body) { hash_body }
44
+
45
+ it "returns a valid Data object" do
46
+ is_expected.to eq Appsignal::Utils::Data.generate(body)
47
+ is_expected.to_not eq Appsignal::Utils::Data.generate({})
48
+ end
49
+
50
+ describe "#to_s" do
51
+ it "returns a serialized hash" do
52
+ expect(subject.to_s).to eq %({"":"test",) +
53
+ %("1":true,) +
54
+ %("bar":null,) +
55
+ %("baz":{"arr":[1,2],"foo":"bʊr"},) +
56
+ %("float":1.0,) +
57
+ %("foo":[1,2,"three",{"foo":"bar"}],) +
58
+ %("int":1,) +
59
+ %("int61":#{1 << 61},) +
60
+ %("int62":#{1 << 62},) +
61
+ %("int63":"bigint:#{1 << 63}",) +
62
+ %("int64":"bigint:#{1 << 64}",) +
63
+ %("the":"payload"})
64
+ end
65
+ end
66
+ end
67
+
68
+ context "with a valid array body" do
69
+ let(:body) { array_body }
70
+
71
+ it "returns a valid Data object" do
72
+ is_expected.to eq Appsignal::Utils::Data.generate(body)
73
+ is_expected.to_not eq Appsignal::Utils::Data.generate({})
74
+ end
75
+
76
+ describe "#to_s" do
77
+ it "returns a serialized array" do
78
+ expect(subject.to_s).to eq %([null,) +
79
+ %(true,) +
80
+ %(false,) +
81
+ %(\"string\",) +
82
+ %(1,) +
83
+ %(1.0,) +
84
+ %(#{1 << 61},) +
85
+ %(#{1 << 62},) +
86
+ %("bigint:#{1 << 63}",) +
87
+ %("bigint:#{1 << 64}",) +
88
+ %({\"arr\":[1,2,\"three\"],\"foo\":\"bʊr\"}])
89
+ end
90
+ end
96
91
  end
97
92
 
98
- describe "#to_s" do
99
- it { expect(subject.to_s).to eq %({"field_four":{"one":"aa�"},"field_one":"aa","field_three":["one","aa�"],"field_two":"aa�"}) }
93
+ context "with a body that contains strings with invalid utf-8 content" do
94
+ let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack("c*") }
95
+ let(:body) do
96
+ {
97
+ "field_one" => [0x61, 0x61].pack("c*"),
98
+ :field_two => string_with_invalid_utf8,
99
+ "field_three" => [
100
+ "one", string_with_invalid_utf8
101
+ ],
102
+ "field_four" => {
103
+ "one" => string_with_invalid_utf8
104
+ }
105
+ }
106
+ end
107
+
108
+ describe "#to_s" do
109
+ it "returns a JSON representation in a String" do
110
+ expect(subject.to_s).to eq %({"field_four":{"one":"aa�"},"field_one":"aa","field_three":["one","aa�"],"field_two":"aa�"})
111
+ end
112
+ end
100
113
  end
101
- end
102
114
 
103
- context "with an invalid body" do
104
- let(:body) { "body" }
115
+ context "with an invalid body" do
116
+ let(:body) { "body" }
105
117
 
106
- it "should raise a type error" do
107
- expect do
108
- subject
109
- end.to raise_error TypeError
118
+ it "raises a type error" do
119
+ expect do
120
+ subject
121
+ end.to raise_error TypeError
122
+ end
110
123
  end
111
124
  end
112
125
  end
126
+
127
+ def hash_body
128
+ {
129
+ "the" => "payload",
130
+ "int" => 1, # Fixnum
131
+ "int61" => 1 << 61, # Fixnum
132
+ "int62" => 1 << 62, # Bignum, this one still works
133
+ "int63" => 1 << 63, # Bignum, turnover point for C, too big for long
134
+ "int64" => 1 << 64, # Bignum
135
+ "float" => 1.0,
136
+ 1 => true,
137
+ nil => "test",
138
+ :foo => [1, 2, "three", { "foo" => "bar" }],
139
+ "bar" => nil,
140
+ "baz" => { "foo" => "bʊr", "arr" => [1, 2] }
141
+ }
142
+ end
143
+
144
+ def array_body
145
+ [
146
+ nil,
147
+ true,
148
+ false,
149
+ "string",
150
+ 1, # Fixnum
151
+ 1.0, # Float
152
+ 1 << 61, # Fixnum
153
+ 1 << 62, # Bignum, this one still works
154
+ 1 << 63, # Bignum, turnover point for C, too big for long
155
+ 1 << 64, # Bignum
156
+ { "arr" => [1, 2, "three"], "foo" => "bʊr" }
157
+ ]
158
+ end
113
159
  end
@@ -770,7 +770,7 @@ describe Appsignal do
770
770
  message = "The namespace argument for `Appsignal.send_error` is deprecated. " \
771
771
  "Please use the block method to set the namespace instead.\n\n" \
772
772
  " Appsignal.send_error(error) do |transaction|\n" \
773
- " transaction.namespace(#{namespace.inspect})\n" \
773
+ " transaction.set_namespace(#{namespace.inspect})\n" \
774
774
  " end\n\n" \
775
775
  "Appsignal.send_error called on location: #{__FILE__}:"
776
776
  expect(stderr).to include("appsignal WARNING: #{message}")
@@ -949,7 +949,7 @@ describe Appsignal do
949
949
  message = "The namespace argument for `Appsignal.set_error` is deprecated. " \
950
950
  "Please use the block method to set the namespace instead.\n\n" \
951
951
  " Appsignal.set_error(error) do |transaction|\n" \
952
- " transaction.namespace(#{namespace.inspect})\n" \
952
+ " transaction.set_namespace(#{namespace.inspect})\n" \
953
953
  " end\n\n" \
954
954
  "Appsignal.set_error called on location: #{__FILE__}:"
955
955
  expect(stderr).to include("appsignal WARNING: #{message}")
@@ -89,7 +89,7 @@ RSpec.describe "Puma plugin" do
89
89
  wait_for("enough probe calls") { probe.calls >= 2 }
90
90
  end
91
91
 
92
- it "marks the PumaProbe thread as fork-safe", :not_ruby19 do
92
+ it "marks the PumaProbe thread as fork-safe" do
93
93
  out_stream = std_stream
94
94
  capture_stdout(out_stream) { Puma.run }
95
95
 
data/spec/spec_helper.rb CHANGED
@@ -117,6 +117,28 @@ RSpec.configure do |config|
117
117
  allow(Appsignal::Config).to receive(:system_tmp_dir).and_return(spec_system_tmp_dir)
118
118
  end
119
119
 
120
+ # These tests are not run by default. They require a failed extension
121
+ # installation. See the `rake test:failure` task. If a test with this tag was
122
+ # run, run `rake extension:install` again to fix the extension installation
123
+ # before running other tests.
124
+ config.before :extension_installation_failure => true do
125
+ next unless Appsignal.extension_loaded?
126
+
127
+ raise "Extension is loaded, please run the following task and rerun the test." \
128
+ "\n\n rake test:prepare_failure"
129
+ end
130
+
131
+ # Check to see if the extension is loaded before running the specs. If the
132
+ # extension is not loaded it can result in unexpected behavior.
133
+ config.before do |example|
134
+ next if Appsignal.extension_loaded?
135
+ next if example.metadata[:extension_installation_failure]
136
+
137
+ puts "\nWARNING: The AppSignal extension is not loaded, please run the "\
138
+ "following task and rerun the test." \
139
+ "\n\n rake extension:install\n"
140
+ end
141
+
120
142
  config.after do
121
143
  Appsignal::Testing.clear!
122
144
  clear_current_transaction!
@@ -1,16 +1,26 @@
1
1
  module Appsignal
2
2
  class << self
3
+ attr_writer :testing
3
4
  remove_method :testing?
4
5
 
5
6
  # @api private
6
7
  def testing?
7
- true
8
+ @testing = true unless defined?(@testing)
9
+ @testing
8
10
  end
9
11
  end
10
12
 
11
13
  # @api private
12
14
  module Testing
13
15
  class << self
16
+ def without_testing
17
+ original_testing = Appsignal.testing?
18
+ Appsignal.testing = false
19
+ yield
20
+ ensure
21
+ Appsignal.testing = original_testing
22
+ end
23
+
14
24
  def transactions
15
25
  @transactions ||= []
16
26
  end
data/support/install_deps CHANGED
@@ -2,25 +2,26 @@
2
2
 
3
3
  set -eu
4
4
 
5
- gem_args="--no-verbose"
6
- if [[ $(ruby --version) != "ruby 1.9.3"* ]]; then
7
- gem_args+=" --no-document"
8
- fi
5
+ gem_args="--no-verbose --no-document"
9
6
 
10
7
  case "${_RUBYGEMS_VERSION-"latest"}" in
11
8
  "latest")
12
- gem update $gem_args --system
9
+ echo "Updating rubygems"
10
+ retry --times 5 --sleep 5 gem update $gem_args --system
13
11
  ;;
14
12
  *)
15
- gem update $gem_args --system $_RUBYGEMS_VERSION
13
+ echo "Updating rubygems to $_RUBYGEMS_VERSION}"
14
+ retry --times 5 --sleep 5 gem update $gem_args --system $_RUBYGEMS_VERSION
16
15
  ;;
17
16
  esac
18
17
 
19
18
  case "${_BUNDLER_VERSION-"latest"}" in
20
19
  "latest")
21
- gem update bundler $gem_args
20
+ echo "Updating bundler"
21
+ retry --times 5 --sleep 5 gem update bundler $gem_args
22
22
  ;;
23
23
  *)
24
- gem install bundler $gem_args --version $_BUNDLER_VERSION
24
+ echo "Updating bundler to $_BUNDLER_VERSION"
25
+ retry --times 5 --sleep 5 gem install bundler $gem_args --version $_BUNDLER_VERSION
25
26
  ;;
26
27
  esac
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.0.2
4
+ version: 3.0.6
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: 2021-03-18 00:00:00.000000000 Z
13
+ date: 2021-05-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -179,8 +179,6 @@ files:
179
179
  - gemfiles/que.gemfile
180
180
  - gemfiles/que_beta.gemfile
181
181
  - gemfiles/rails-3.2.gemfile
182
- - gemfiles/rails-4.0.gemfile
183
- - gemfiles/rails-4.1.gemfile
184
182
  - gemfiles/rails-4.2.gemfile
185
183
  - gemfiles/rails-5.0.gemfile
186
184
  - gemfiles/rails-5.1.gemfile
@@ -226,6 +224,7 @@ files:
226
224
  - lib/appsignal/hooks/celluloid.rb
227
225
  - lib/appsignal/hooks/data_mapper.rb
228
226
  - lib/appsignal/hooks/delayed_job.rb
227
+ - lib/appsignal/hooks/excon.rb
229
228
  - lib/appsignal/hooks/mongo_ruby_driver.rb
230
229
  - lib/appsignal/hooks/net_http.rb
231
230
  - lib/appsignal/hooks/passenger.rb
@@ -245,6 +244,7 @@ files:
245
244
  - lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
246
245
  - lib/appsignal/integrations/data_mapper.rb
247
246
  - lib/appsignal/integrations/delayed_job_plugin.rb
247
+ - lib/appsignal/integrations/excon.rb
248
248
  - lib/appsignal/integrations/grape.rb
249
249
  - lib/appsignal/integrations/mongo_ruby_driver.rb
250
250
  - lib/appsignal/integrations/net_http.rb
@@ -282,6 +282,7 @@ files:
282
282
  - lib/appsignal/version.rb
283
283
  - lib/puma/plugin/appsignal.rb
284
284
  - lib/sequel/extensions/appsignal_integration.rb
285
+ - mono.yml
285
286
  - resources/appsignal.yml.erb
286
287
  - resources/cacert.pem
287
288
  - spec/.rubocop.yml
@@ -320,6 +321,7 @@ files:
320
321
  - spec/lib/appsignal/hooks/celluloid_spec.rb
321
322
  - spec/lib/appsignal/hooks/data_mapper_spec.rb
322
323
  - spec/lib/appsignal/hooks/delayed_job_spec.rb
324
+ - spec/lib/appsignal/hooks/excon_spec.rb
323
325
  - spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
324
326
  - spec/lib/appsignal/hooks/net_http_spec.rb
325
327
  - spec/lib/appsignal/hooks/passenger_spec.rb
@@ -427,7 +429,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
427
429
  - !ruby/object:Gem::Version
428
430
  version: '0'
429
431
  requirements: []
430
- rubygems_version: 3.2.8
432
+ rubygems_version: 3.2.17
431
433
  signing_key:
432
434
  specification_version: 4
433
435
  summary: Logs performance and exception data from your app to appsignal.com
@@ -468,6 +470,7 @@ test_files:
468
470
  - spec/lib/appsignal/hooks/celluloid_spec.rb
469
471
  - spec/lib/appsignal/hooks/data_mapper_spec.rb
470
472
  - spec/lib/appsignal/hooks/delayed_job_spec.rb
473
+ - spec/lib/appsignal/hooks/excon_spec.rb
471
474
  - spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
472
475
  - spec/lib/appsignal/hooks/net_http_spec.rb
473
476
  - spec/lib/appsignal/hooks/passenger_spec.rb