appsignal 2.10.4 → 2.10.6

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.
@@ -323,11 +323,11 @@ describe Appsignal::Config do
323
323
  end
324
324
 
325
325
  describe "support for old config keys" do
326
- let(:out_stream) { std_stream }
327
- let(:output) { out_stream.read }
326
+ let(:err_stream) { std_stream }
327
+ let(:stderr) { err_stream.read }
328
328
  let(:config) { project_fixture_config(env, {}, test_logger(log)) }
329
329
  let(:log) { StringIO.new }
330
- before { capture_stdout(out_stream) { config } }
330
+ before { capture_std_streams(std_stream, err_stream) { config } }
331
331
 
332
332
  describe ":api_key" do
333
333
  context "without :push_api_key" do
@@ -338,7 +338,7 @@ describe Appsignal::Config do
338
338
  expect(config.config_hash).to_not have_key :api_key
339
339
 
340
340
  message = "Old configuration key found. Please update the 'api_key' to 'push_api_key'"
341
- expect(output).to include "appsignal WARNING: #{message}"
341
+ expect(stderr).to include "appsignal WARNING: #{message}"
342
342
  expect(log_contents(log)).to contains_log :warn, message
343
343
  end
344
344
  end
@@ -351,7 +351,7 @@ describe Appsignal::Config do
351
351
  expect(config.config_hash).to_not have_key :api_key
352
352
 
353
353
  message = "Old configuration key found. Please update the 'api_key' to 'push_api_key'"
354
- expect(output).to include "appsignal WARNING: #{message}"
354
+ expect(stderr).to include "appsignal WARNING: #{message}"
355
355
  expect(log_contents(log)).to contains_log :warn, message
356
356
  end
357
357
  end
@@ -366,7 +366,7 @@ describe Appsignal::Config do
366
366
  expect(config.config_hash).to_not have_key :ignore_exceptions
367
367
 
368
368
  message = "Old configuration key found. Please update the 'ignore_exceptions' to 'ignore_errors'"
369
- expect(output).to include "appsignal WARNING: #{message}"
369
+ expect(stderr).to include "appsignal WARNING: #{message}"
370
370
  expect(log_contents(log)).to contains_log :warn, message
371
371
  end
372
372
  end
@@ -379,7 +379,7 @@ describe Appsignal::Config do
379
379
  expect(config.config_hash).to_not have_key :ignore_exceptions
380
380
 
381
381
  message = "Old configuration key found. Please update the 'ignore_exceptions' to 'ignore_errors'"
382
- expect(output).to include "appsignal WARNING: #{message}"
382
+ expect(stderr).to include "appsignal WARNING: #{message}"
383
383
  expect(log_contents(log)).to contains_log :warn, message
384
384
  end
385
385
  end
@@ -116,7 +116,8 @@ describe Appsignal::EventFormatter do
116
116
  end
117
117
 
118
118
  context "when registering deprecated formatters" do
119
- let(:stdout_stream) { std_stream }
119
+ let(:err_stream) { std_stream }
120
+ let(:stderr) { err_stream.read }
120
121
  let(:deprecated_formatter) do
121
122
  Class.new(Appsignal::EventFormatter) do
122
123
  register "mock.deprecated"
@@ -133,16 +134,16 @@ describe Appsignal::EventFormatter do
133
134
  "https://docs.appsignal.com/ruby/instrumentation/event-formatters.html"
134
135
 
135
136
  logs = capture_logs do
136
- capture_stdout(stdout_stream) { deprecated_formatter }
137
+ capture_std_streams(std_stream, err_stream) { deprecated_formatter }
137
138
  end
138
139
  expect(logs).to contains_log :warn, message
139
- expect(stdout_stream.read).to include "appsignal WARNING: #{message}"
140
+ expect(stderr).to include "appsignal WARNING: #{message}"
140
141
 
141
142
  expect(klass.deprecated_formatter_classes.keys).to include("mock.deprecated")
142
143
  end
143
144
 
144
145
  it "initializes deprecated formatters" do
145
- capture_stdout(stdout_stream) { deprecated_formatter }
146
+ capture_std_streams(std_stream, err_stream) { deprecated_formatter }
146
147
  klass.initialize_deprecated_formatters
147
148
 
148
149
  expect(klass.registered?("mock.deprecated")).to be_truthy
@@ -93,6 +93,16 @@ if DependencyHelper.grape_present?
93
93
  expect(transaction).to receive(:set_error).with(kind_of(ExampleException))
94
94
  end
95
95
 
96
+ context "with env['grape.skip_appsignal_error'] = true" do
97
+ before do
98
+ env["grape.skip_appsignal_error"] = true
99
+ end
100
+
101
+ it "does not add the error" do
102
+ expect(transaction).to_not receive(:set_error)
103
+ end
104
+ end
105
+
96
106
  after do
97
107
  expect { middleware.call(env) }.to raise_error ExampleException
98
108
  end
@@ -285,19 +285,19 @@ describe Appsignal::Minutely do
285
285
  end
286
286
 
287
287
  describe "#<<" do
288
- let(:out_stream) { std_stream }
289
- let(:output) { out_stream.read }
288
+ let(:err_stream) { std_stream }
289
+ let(:stderr) { err_stream.read }
290
290
  let(:log_stream) { std_stream }
291
291
  let(:log) { log_contents(log_stream) }
292
292
  before { Appsignal.logger = test_logger(log_stream) }
293
293
 
294
294
  it "adds the probe, but prints a deprecation warning" do
295
295
  probe = lambda {}
296
- capture_stdout(out_stream) { collection << probe }
296
+ capture_std_streams(std_stream, err_stream) { collection << probe }
297
297
  deprecation_message = "Deprecated " \
298
298
  "`Appsignal::Minute.probes <<` call. Please use " \
299
299
  "`Appsignal::Minutely.probes.register` instead."
300
- expect(output).to include "appsignal WARNING: #{deprecation_message}"
300
+ expect(stderr).to include "appsignal WARNING: #{deprecation_message}"
301
301
  expect(log).to contains_log :warn, deprecation_message
302
302
  expect(collection[probe.object_id]).to eql(probe)
303
303
  end
@@ -11,18 +11,22 @@ describe Appsignal::Rack::JSExceptionCatcher do
11
11
  before { Appsignal.config = config }
12
12
 
13
13
  describe "#initialize" do
14
+ let(:out_stream) { std_stream }
15
+ let(:err_stream) { std_stream }
16
+ let(:output) { out_stream.read }
17
+ let(:stderr) { err_stream.read }
18
+
14
19
  it "logs to the logger" do
15
- stdout = std_stream
16
- stderr = std_stream
17
20
  log = capture_logs do
18
- capture_std_streams(stdout, stderr) do
21
+ capture_std_streams(out_stream, err_stream) do
19
22
  Appsignal::Rack::JSExceptionCatcher.new(app, options)
20
23
  end
21
24
  end
22
25
  expect(log).to contains_log(:warn, deprecation_message)
23
26
  expect(log).to contains_log(:debug, "Initializing Appsignal::Rack::JSExceptionCatcher")
24
- expect(stdout.read).to include "appsignal WARNING: #{deprecation_message}"
25
- expect(stderr.read).to_not include("appsignal:")
27
+ expect(stderr).to include "appsignal WARNING: #{deprecation_message}"
28
+ expect(stderr).to_not include("appsignal:")
29
+ expect(output).to be_empty
26
30
  end
27
31
  end
28
32
 
@@ -93,4 +93,40 @@ describe Appsignal::System do
93
93
  end
94
94
  end
95
95
  end
96
+
97
+ describe ".ruby_2_or_up?" do
98
+ around do |example|
99
+ original_ruby_version = RUBY_VERSION
100
+ Object.send(:remove_const, "RUBY_VERSION")
101
+ Object.const_set("RUBY_VERSION", ruby_version)
102
+ example.run
103
+ Object.send(:remove_const, "RUBY_VERSION")
104
+ Object.const_set("RUBY_VERSION", original_ruby_version)
105
+ end
106
+ subject { described_class.ruby_2_or_up? }
107
+
108
+ context "when on Ruby 1.9" do
109
+ let(:ruby_version) { "1.9.3-p533" }
110
+
111
+ it "returns false" do
112
+ is_expected.to be(false)
113
+ end
114
+ end
115
+
116
+ context "when on Ruby 2.0" do
117
+ let(:ruby_version) { "2.0.0" }
118
+
119
+ it "returns true" do
120
+ is_expected.to be(true)
121
+ end
122
+ end
123
+
124
+ context "when on Ruby 2.x" do
125
+ let(:ruby_version) { "2.1.0" }
126
+
127
+ it "returns true" do
128
+ is_expected.to be(true)
129
+ end
130
+ end
131
+ end
96
132
  end
@@ -574,7 +574,7 @@ describe Appsignal::Transaction do
574
574
  end
575
575
 
576
576
  context "when the data cannot be converted to JSON" do
577
- it "does not update the sample data on the transaction" do
577
+ it "does not update the sample data on the transaction", :not_ruby19 do
578
578
  klass = Class.new do
579
579
  def to_s
580
580
  raise "foo" # Cause a deliberate error
@@ -586,6 +586,19 @@ describe Appsignal::Transaction do
586
586
  expect(log_contents(log)).to contains_log :error,
587
587
  "Error generating data (RuntimeError: foo) for"
588
588
  end
589
+
590
+ it "does not update the sample data on the transaction", :only_ruby19 do
591
+ klass = Class.new do
592
+ def to_s
593
+ raise "foo" # Cause a deliberate error
594
+ end
595
+ end
596
+ transaction.set_sample_data("params", klass.new => 1)
597
+
598
+ expect(transaction.to_h["sample_data"]).to eq({})
599
+ expect(log_contents(log)).to contains_log :error,
600
+ "Error generating data (RuntimeError: foo). Can't inspect data."
601
+ end
589
602
  end
590
603
  end
591
604
 
@@ -143,7 +143,9 @@ describe Appsignal::Transmitter do
143
143
  context "with a proxy" do
144
144
  let(:config) { project_fixture_config("production", :http_proxy => "http://localhost:8080") }
145
145
 
146
- it { expect(subject).to be_instance_of(Net::HTTP) }
146
+ it "is of Net::HTTP class", :not_ruby19 do
147
+ expect(subject).to be_instance_of(Net::HTTP)
148
+ end
147
149
  it { expect(subject.proxy?).to be_truthy }
148
150
  it { expect(subject.proxy_address).to eq "localhost" }
149
151
  it { expect(subject.proxy_port).to eq 8080 }
@@ -949,7 +949,7 @@ describe Appsignal do
949
949
 
950
950
  it "outputs deprecated warning" do
951
951
  subject
952
- expect(stderr).to include("Appsignal.is_ignored_error? is deprecated with no replacement.")
952
+ expect(stderr).to include("Appsignal.is_ignored_error? is deprecated with no replacement")
953
953
  end
954
954
 
955
955
  context "when error is not in the ignored list" do
@@ -981,7 +981,7 @@ describe Appsignal do
981
981
 
982
982
  it "outputs deprecated warning" do
983
983
  subject
984
- expect(stderr).to include("Appsignal.is_ignored_action? is deprecated with no replacement.")
984
+ expect(stderr).to include("Appsignal.is_ignored_action? is deprecated with no replacement")
985
985
  end
986
986
 
987
987
  context "when action is not in the ingore list" do
@@ -9,7 +9,6 @@ Bundler.require :default
9
9
  require "cgi"
10
10
  require "rack"
11
11
  require "rspec"
12
- require "pry"
13
12
  require "timecop"
14
13
  require "webmock/rspec"
15
14
 
@@ -30,6 +29,7 @@ if DependencyHelper.rails_present?
30
29
  require f
31
30
  end
32
31
  end
32
+ require "pry" if DependencyHelper.dependency_present?("pry")
33
33
  require "appsignal"
34
34
  # Include patches of AppSignal modules and classes to make test helpers
35
35
  # available.
@@ -81,6 +81,20 @@ RSpec.configure do |config|
81
81
  FileUtils.mkdir_p(spec_system_tmp_dir)
82
82
  end
83
83
 
84
+ config.before :each, :only_ruby19 => true do
85
+ is_ruby19 = Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.0.0")
86
+ next if is_ruby19
87
+
88
+ skip "Skipping spec. Only for Ruby 1.9"
89
+ end
90
+
91
+ config.before :each, :not_ruby19 => true do
92
+ is_ruby19 = Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.0.0")
93
+ next unless is_ruby19
94
+
95
+ skip "Skipping spec for Ruby 1.9"
96
+ end
97
+
84
98
  config.before do
85
99
  stop_minutely_probes
86
100
  ENV["RAILS_ENV"] ||= "test"
@@ -2,7 +2,10 @@
2
2
 
3
3
  set -eu
4
4
 
5
- gem_args="--no-document --no-verbose"
5
+ gem_args="--no-verbose"
6
+ if [[ $(ruby --version) != "ruby 1.9.3"* ]]; then
7
+ gem_args+=" --no-document"
8
+ fi
6
9
 
7
10
  case "${_RUBYGEMS_VERSION-"latest"}" in
8
11
  "latest")
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: 2.10.4
4
+ version: 2.10.6
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: 2020-02-28 00:00:00.000000000 Z
13
+ date: 2020-04-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -55,7 +55,7 @@ dependencies:
55
55
  - !ruby/object:Gem::Version
56
56
  version: '3.8'
57
57
  - !ruby/object:Gem::Dependency
58
- name: pry
58
+ name: timecop
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
@@ -69,7 +69,7 @@ dependencies:
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  - !ruby/object:Gem::Dependency
72
- name: timecop
72
+ name: webmock
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - ">="
@@ -83,47 +83,47 @@ dependencies:
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  - !ruby/object:Gem::Dependency
86
- name: webmock
86
+ name: yard
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ">="
90
90
  - !ruby/object:Gem::Version
91
- version: '0'
91
+ version: 0.9.20
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - ">="
97
97
  - !ruby/object:Gem::Version
98
- version: '0'
98
+ version: 0.9.20
99
99
  - !ruby/object:Gem::Dependency
100
- name: rubocop
100
+ name: pry
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - '='
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
- version: 0.50.0
105
+ version: '0'
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - '='
110
+ - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: 0.50.0
112
+ version: '0'
113
113
  - !ruby/object:Gem::Dependency
114
- name: yard
114
+ name: rubocop
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ">="
117
+ - - '='
118
118
  - !ruby/object:Gem::Version
119
- version: 0.9.20
119
+ version: 0.50.0
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ">="
124
+ - - '='
125
125
  - !ruby/object:Gem::Version
126
- version: 0.9.20
126
+ version: 0.50.0
127
127
  description: The official appsignal.com gem
128
128
  email:
129
129
  - support@appsignal.com
@@ -227,6 +227,7 @@ files:
227
227
  - lib/appsignal/integrations/delayed_job_plugin.rb
228
228
  - lib/appsignal/integrations/grape.rb
229
229
  - lib/appsignal/integrations/mongo_ruby_driver.rb
230
+ - lib/appsignal/integrations/net_http.rb
230
231
  - lib/appsignal/integrations/object.rb
231
232
  - lib/appsignal/integrations/padrino.rb
232
233
  - lib/appsignal/integrations/que.rb