appsignal 3.0.2-java → 3.0.3-java

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4c1518cad816207b3557eea011da997613e729475852662952c2365ad61acdb
4
- data.tar.gz: '03287ec510d51de0d45c7f7d40d1737ea398e35e951e28e03d0b1251e11742a2'
3
+ metadata.gz: 454de643d80064e792ed79a2bd87adb3ea768ffcb01da936b27d95ddca139144
4
+ data.tar.gz: db6447c34dc0e45d7988bfb084caaf8f56cf609028eaf25dbafe47f07fda07a6
5
5
  SHA512:
6
- metadata.gz: f93173286061b6c80628713c1317019e7a6300c0259fca4fa0d54ff5387ee418f076972e676f9727b442acc91146946c403b83e16bb4f0de563c139e4ddd5f77
7
- data.tar.gz: 430a7442eca749d01805fade52d038408e19f8315807338896a5ab003ae9ad14b7d7109e9b2055050db2ee2c3d6e326f8f111879d5bd46925c5dcf3526c8f974
6
+ metadata.gz: c04aed61e2ae00233877d3f0f2f31d20634909bea59533ac338951a8df7a9cf24814800a411514f3bf0b50bf4835526d6cad3855dea739ffcdfbe942d104e8f4
7
+ data.tar.gz: de61c1a331567370f8ac6ad3acc7375d732fd91c04c4a53d983786557bb7c6655dd3080d8b7d79a0e86af30b7fe3e7bc53a0b0fa54e7089bcc8b3bab6fe854e3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ # 3.0.3
4
+ - Fix deprecation message for set_error namespace argument. PR #712
5
+ - Fix example code for Transaction#set_namespace method. PR #713
6
+ - Fix extension fallbacks on extension installation failure, that caused
7
+ - NoMethodErrors. PR #720
8
+ - Bump agent to v-75e76ad. PR #721
9
+
3
10
  # 3.0.2
4
11
  - Fix error on Rails boot when `enable_frontend_error_catching` is `true`.
5
12
  PR #711
data/Rakefile CHANGED
@@ -377,8 +377,6 @@ begin
377
377
  is_jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
378
378
  excludes = []
379
379
  excludes << "spec/lib/appsignal/extension/jruby_spec.rb" unless is_jruby
380
- is_ruby19 = RUBY_VERSION < "2.0"
381
- excludes << "spec/lib/appsignal/integrations/object_spec.rb" if is_ruby19
382
380
  exclude_pattern = "--exclude-pattern=#{excludes.join(",")}" if excludes.any?
383
381
 
384
382
  desc "Run the AppSignal gem test suite."
@@ -387,10 +385,20 @@ begin
387
385
  end
388
386
 
389
387
  namespace :test do
390
- desc "Run the Appsignal gem test in an extension failure scenario"
391
- RSpec::Core::RakeTask.new :failure do |t|
388
+ RSpec::Core::RakeTask.new :rspec_failure do |t|
392
389
  t.rspec_opts = "#{exclude_pattern} --tag extension_installation_failure"
393
390
  end
391
+
392
+ desc "Intentionally fail the extension installation"
393
+ task :prepare_failure do
394
+ # ENV var to make sure installation fails on purpurse
395
+ ENV["_TEST_APPSIGNAL_EXTENSION_FAILURE"] = "true"
396
+ # Run extension installation with intentional failure
397
+ `rake extension:install`
398
+ end
399
+
400
+ desc "Run the Appsignal gem test in an extension failure scenario"
401
+ task :failure => [:prepare_failure, :rspec_failure]
394
402
  end
395
403
  rescue LoadError # rubocop:disable Lint/HandleExceptions
396
404
  # When running rake install, there is no RSpec yet.
data/appsignal.gemspec CHANGED
@@ -42,9 +42,11 @@ Gem::Specification.new do |gem| # rubocop:disable Metrics/BlockLength
42
42
  gem.add_development_dependency "timecop"
43
43
  gem.add_development_dependency "webmock"
44
44
  gem.add_development_dependency "yard", ">= 0.9.20"
45
- is_modern_ruby = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.0.0")
46
- if is_modern_ruby
47
- gem.add_development_dependency "pry"
48
- gem.add_development_dependency "rubocop", "0.50.0"
45
+ gem.add_development_dependency "pry"
46
+ gem.add_development_dependency "rubocop", "0.50.0"
47
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1.0")
48
+ # Newer versions of rexml use keyword arguments with optional arguments which
49
+ # work in Ruby 2.1 and newer.
50
+ gem.add_development_dependency "rexml", "3.2.4"
49
51
  end
50
52
  end
data/ext/agent.yml CHANGED
@@ -1,62 +1,62 @@
1
1
  ---
2
- version: d98461b
2
+ version: 75e76ad
3
3
  mirrors:
4
4
  - https://appsignal-agent-releases.global.ssl.fastly.net
5
5
  - https://d135dj0rjqvssy.cloudfront.net
6
6
  triples:
7
7
  x86_64-darwin:
8
8
  static:
9
- checksum: 178ab2329c7b29cf45140e4707e75c20379fa0c7dfd7f39266a7a95aea510780
9
+ checksum: 81edea50b934fe5b42c0081a1de5782bc477c321c1c76127d7fa525917f70a04
10
10
  filename: appsignal-x86_64-darwin-all-static.tar.gz
11
11
  dynamic:
12
- checksum: '0923985cc78c5cf278f45d530679954b94b1a91c87453369116fc05525e29864'
12
+ checksum: 60befd59ac704ee21d5881ca0aef6b38caa50b1d1972425bf8f40b4f9710ec1e
13
13
  filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
14
14
  universal-darwin:
15
15
  static:
16
- checksum: 178ab2329c7b29cf45140e4707e75c20379fa0c7dfd7f39266a7a95aea510780
16
+ checksum: 81edea50b934fe5b42c0081a1de5782bc477c321c1c76127d7fa525917f70a04
17
17
  filename: appsignal-x86_64-darwin-all-static.tar.gz
18
18
  dynamic:
19
- checksum: '0923985cc78c5cf278f45d530679954b94b1a91c87453369116fc05525e29864'
19
+ checksum: 60befd59ac704ee21d5881ca0aef6b38caa50b1d1972425bf8f40b4f9710ec1e
20
20
  filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
21
21
  i686-linux:
22
22
  static:
23
- checksum: cb772a8a178edb25d666b650efda80149c98e80e4264435d6176f8a6104f959a
23
+ checksum: 60ad6a1f69c8f89b5642f49fbf794409e8ada7d63a9126b2c59832c2a92d5b22
24
24
  filename: appsignal-i686-linux-all-static.tar.gz
25
25
  dynamic:
26
- checksum: c9ac51f4d1b3cc13773d8fa8ea5cfad6af7909144d85186cef9324ec0531bdac
26
+ checksum: aedf259de392ea00fd17bc30924cde70d9a1d82a62c6eeefc881cd5ea5dcce63
27
27
  filename: appsignal-i686-linux-all-dynamic.tar.gz
28
28
  x86-linux:
29
29
  static:
30
- checksum: cb772a8a178edb25d666b650efda80149c98e80e4264435d6176f8a6104f959a
30
+ checksum: 60ad6a1f69c8f89b5642f49fbf794409e8ada7d63a9126b2c59832c2a92d5b22
31
31
  filename: appsignal-i686-linux-all-static.tar.gz
32
32
  dynamic:
33
- checksum: c9ac51f4d1b3cc13773d8fa8ea5cfad6af7909144d85186cef9324ec0531bdac
33
+ checksum: aedf259de392ea00fd17bc30924cde70d9a1d82a62c6eeefc881cd5ea5dcce63
34
34
  filename: appsignal-i686-linux-all-dynamic.tar.gz
35
35
  x86_64-linux:
36
36
  static:
37
- checksum: d6c280e992d74f97d59da9827ec5707ca4f6776b0568cde1c083c1113e4b7104
37
+ checksum: 7e3cf760f9bd364a6602f05e5014ce1c8e8ac9a97f7a533769711e0fb21e1f45
38
38
  filename: appsignal-x86_64-linux-all-static.tar.gz
39
39
  dynamic:
40
- checksum: ef1a3f5d4b2ed61ea2ae4d5cb1a261a0e685fb9d3e7ea9efe455498aad386e59
40
+ checksum: 4a9a4ea22abc93c3afa7d5bfd6f442cd69bf4d672e8db2df1aa2157cfb3fcc4b
41
41
  filename: appsignal-x86_64-linux-all-dynamic.tar.gz
42
42
  x86_64-linux-musl:
43
43
  static:
44
- checksum: 9cf8ad34392662746a45cfce18113ad19cc29954789e2058f30e527163f2e98a
44
+ checksum: 4d4dd00607cbe0fb4d14a15e74990f207eba90134c2d1a079b58f0d50f1ab76b
45
45
  filename: appsignal-x86_64-linux-musl-all-static.tar.gz
46
46
  dynamic:
47
- checksum: 01bd76983227648d9bc41d035e1552fcf18d62f0d6818bf7bb7fc2e7c166513d
47
+ checksum: 067a6d821e220c9c88ceb8f936390ce458fa94f41c13d32603d773485a8cdfd2
48
48
  filename: appsignal-x86_64-linux-musl-all-dynamic.tar.gz
49
49
  x86_64-freebsd:
50
50
  static:
51
- checksum: 403a597cbdbdba08460c5c9e93347ed9ad1d24333204e6d72db342deb266a296
51
+ checksum: 176bc1ff1ad40a585ea10456a8ae3f6502c614d713dcbb957d550fa1ae44e7ca
52
52
  filename: appsignal-x86_64-freebsd-all-static.tar.gz
53
53
  dynamic:
54
- checksum: a1faae80ae09a6588c4cd35cb91dfa4b2176fc3cb17fbf79db80194c21e75bf9
54
+ checksum: 88c6f3e03f8f6c25a4705f7d6c4286eaa563069a9fb8fad3c0a19e5b9a09f80b
55
55
  filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
56
56
  amd64-freebsd:
57
57
  static:
58
- checksum: 403a597cbdbdba08460c5c9e93347ed9ad1d24333204e6d72db342deb266a296
58
+ checksum: 176bc1ff1ad40a585ea10456a8ae3f6502c614d713dcbb957d550fa1ae44e7ca
59
59
  filename: appsignal-x86_64-freebsd-all-static.tar.gz
60
60
  dynamic:
61
- checksum: a1faae80ae09a6588c4cd35cb91dfa4b2176fc3cb17fbf79db80194c21e75bf9
61
+ checksum: 88c6f3e03f8f6c25a4705f7d6c4286eaa563069a9fb8fad3c0a19e5b9a09f80b
62
62
  filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
@@ -2,11 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rack', '~> 1.6'
4
4
 
5
- ruby_version = Gem::Version.new(RUBY_VERSION)
6
- if ruby_version < Gem::Version.new("2.0.0")
7
- # Newer versions of this gem have rexml as a dependency which doesn't work on
8
- # Ruby 1.9
9
- gem "crack", "0.4.4"
10
- end
11
-
12
5
  gemspec :path => '../'
@@ -40,6 +40,16 @@ module Appsignal
40
40
  def method_missing(m, *args, &block)
41
41
  super if Appsignal.testing?
42
42
  end
43
+
44
+ unless Appsignal.extension_loaded?
45
+ def data_map_new
46
+ Appsignal::Extension::MockData.new
47
+ end
48
+
49
+ def data_array_new
50
+ Appsignal::Extension::MockData.new
51
+ end
52
+ end
43
53
  end
44
54
 
45
55
  if Appsignal::System.jruby?
@@ -62,5 +72,45 @@ module Appsignal
62
72
  "#<#{self.class.name}:#{object_id} #{self}>"
63
73
  end
64
74
  end
75
+
76
+ # Mock of the {Data} class. This mock is used when the extension cannot be
77
+ # loaded. This mock listens to all method calls and does nothing, and
78
+ # prevents NoMethodErrors from being raised.
79
+ #
80
+ # Disabled in testing so we can make sure that we don't miss an extension
81
+ # function implementation.
82
+ #
83
+ # This class inherits from the {Data} class so that it passes type checks.
84
+ class MockData < Data
85
+ def initialize(*_args)
86
+ # JRuby extension requirement, as it sends a pointer to the Data object
87
+ # when creating it
88
+ end
89
+
90
+ def method_missing(_method, *_args, &_block)
91
+ super if Appsignal.testing?
92
+ end
93
+
94
+ def to_s
95
+ "{}"
96
+ end
97
+ end
98
+
99
+ # Mock of the {Transaction} class. This mock is used when the extension
100
+ # cannot be loaded. This mock listens to all method calls and does nothing,
101
+ # and prevents NoMethodErrors from being raised.
102
+ #
103
+ # Disabled in testing so we can make sure that we don't miss an extension
104
+ # function implementation.
105
+ class MockTransaction
106
+ def initialize(*_args)
107
+ # JRuby extension requirement, as it sends a pointer to the Transaction
108
+ # object when creating it
109
+ end
110
+
111
+ def method_missing(_method, *_args, &_block)
112
+ super if Appsignal.testing?
113
+ end
114
+ end
65
115
  end
66
116
  end
@@ -223,7 +223,7 @@ module Appsignal
223
223
  "The namespace argument for `Appsignal.send_error` is deprecated. " \
224
224
  "Please use the block method to set the namespace instead.\n\n" \
225
225
  " Appsignal.send_error(error) do |transaction|\n" \
226
- " transaction.namespace(#{namespace.inspect})\n" \
226
+ " transaction.set_namespace(#{namespace.inspect})\n" \
227
227
  " end\n\n" \
228
228
  "Appsignal.send_error called on location: #{call_location}"
229
229
  end
@@ -316,7 +316,7 @@ module Appsignal
316
316
  "The namespace argument for `Appsignal.set_error` is deprecated. " \
317
317
  "Please use the block method to set the namespace instead.\n\n" \
318
318
  " Appsignal.set_error(error) do |transaction|\n" \
319
- " transaction.namespace(#{namespace.inspect})\n" \
319
+ " transaction.set_namespace(#{namespace.inspect})\n" \
320
320
  " end\n\n" \
321
321
  "Appsignal.set_error called on location: #{call_location}"
322
322
  end
@@ -90,7 +90,7 @@ module Appsignal
90
90
  @transaction_id,
91
91
  @namespace,
92
92
  self.class.garbage_collection_profiler.total_time
93
- )
93
+ ) || Appsignal::Extension::MockTransaction.new
94
94
  end
95
95
 
96
96
  def nil_transaction?
@@ -228,7 +228,7 @@ module Appsignal
228
228
  # "Web" and "background_job" gets transformed to "Background".
229
229
  #
230
230
  # @example
231
- # transaction.set_action("admin")
231
+ # transaction.set_namespace("background")
232
232
  #
233
233
  # @param namespace [String] namespace name to use for this transaction.
234
234
  # @return [void]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.0.2".freeze
4
+ VERSION = "3.0.3".freeze
5
5
  end
@@ -1,13 +1,6 @@
1
1
  describe Appsignal::Extension, :extension_installation_failure do
2
2
  context "when the extension library cannot be loaded" do
3
- # This test breaks the installation on purpose and is not run by default.
4
- # See `rake test:failure`. If this test was run, run `rake
5
- # extension:install` again to fix the extension installation.
6
3
  it "prints and logs an error" do
7
- # ENV var to make sure installation fails on purpurse
8
- ENV["_TEST_APPSIGNAL_EXTENSION_FAILURE"] = "true"
9
- `rake extension:install` # Run installation
10
-
11
4
  require "open3"
12
5
  _stdout, stderr, _status = Open3.capture3("bin/appsignal --version")
13
6
  expect(stderr).to include("ERROR: AppSignal failed to load extension")
@@ -119,22 +119,56 @@ describe Appsignal::Extension do
119
119
  end
120
120
  end
121
121
 
122
- context "when the extension library cannot be loaded" do
123
- subject { Appsignal::Extension }
122
+ context "when the extension library cannot be loaded", :extension_installation_failure do
123
+ let(:ext) { Appsignal::Extension }
124
124
 
125
- before do
126
- allow(Appsignal).to receive(:extension_loaded).and_return(false)
127
- allow(Appsignal).to receive(:testing?).and_return(false)
125
+ around do |example|
126
+ Appsignal::Testing.without_testing { example.run }
128
127
  end
129
128
 
130
129
  it "should indicate that the extension is not loaded" do
131
130
  expect(Appsignal.extension_loaded?).to be_falsy
132
131
  end
133
132
 
134
- it "should not raise errors when methods are called" do
135
- expect do
136
- subject.something
137
- end.not_to raise_error
133
+ it "does not raise errors when methods are called" do
134
+ ext.appsignal_start
135
+ ext.something
136
+ end
137
+
138
+ describe Appsignal::Extension::MockData do
139
+ it "does not error on missing data_map_new extension method calls" do
140
+ map = ext.data_map_new
141
+ expect(map).to be_kind_of(Appsignal::Extension::MockData)
142
+ # Does not raise errors any arbitrary method call that does not exist
143
+ map.set_string("key", "value")
144
+ map.set_int("key", 123)
145
+ map.something
146
+ end
147
+
148
+ it "does not error on missing data_array_new extension method calls" do
149
+ array = ext.data_array_new
150
+ expect(array).to be_kind_of(Appsignal::Extension::MockData)
151
+ # Does not raise errors any arbitrary method call that does not exist
152
+ array.append_string("value")
153
+ array.append_int(123)
154
+ array.something
155
+ end
156
+ end
157
+
158
+ describe Appsignal::Extension::MockTransaction do
159
+ it "does not error on missing transaction extension method calls" do
160
+ transaction = described_class.new
161
+
162
+ transaction.start_event(0)
163
+ transaction.finish_event(
164
+ "name",
165
+ "title",
166
+ "body",
167
+ Appsignal::EventFormatter::DEFAULT,
168
+ 0
169
+ )
170
+ transaction.something
171
+ end
138
172
  end
139
173
  end
140
174
  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
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.3
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-04-21 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
@@ -427,7 +425,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
427
425
  - !ruby/object:Gem::Version
428
426
  version: '0'
429
427
  requirements: []
430
- rubygems_version: 3.2.8
428
+ rubygems_version: 3.2.16
431
429
  signing_key:
432
430
  specification_version: 4
433
431
  summary: Logs performance and exception data from your app to appsignal.com
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rails', '~> 4.0.0'
4
- gem 'mime-types', '~> 2.6'
5
-
6
- gemspec :path => '../'
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rails', '~> 4.1.0'
4
- gem 'mime-types', '~> 2.6'
5
-
6
- gemspec :path => '../'