appsignal 2.2.0 → 2.2.1

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
  SHA1:
3
- metadata.gz: 21ea8fda4d2d6bea2c6a3a5225bcf2f31635eb8e
4
- data.tar.gz: a2191345607fbff0eae62ff4c74536e85dc16c90
3
+ metadata.gz: 705384b1874c28d97c9686459bcbfc6a99fb2314
4
+ data.tar.gz: d191875adb5dadac78d8148828a346e9165964a4
5
5
  SHA512:
6
- metadata.gz: 8e9b7f50c4e8c4b8736b5d570288522aee4cfd0a75e1fab24ab6c9701b3e01593b8eacea36d86d1e0b8efe4ebd3fb3228beb740d40988a80aa9df2b3d861f282
7
- data.tar.gz: 031661f930c29f14f7f5653b24bc5ffcf749313f16fda86e69e034defabb0fa958b454f0522bd888586b2365e8b1cc2e20a2f17570958104e6f24f8fa449799e
6
+ metadata.gz: fd0dc31ae1795897907da34b6ce862777829e81b6e98013830caa4818bf17f77f683e4a6beb176d6664213f5e64bd602df410aedab8ac798b58432dc0417daa5
7
+ data.tar.gz: 7a448280ea51c4426e6a9322f8a264fe99f94c25312dd663cdd489d8d9f9ac58d81e5f21e154fb309a9fcc035fc23fbcfc7ea98394597305ae49ad021356f167
@@ -1,3 +1,10 @@
1
+ # 2.2.1
2
+ * Fix support for Rails 5.1. PR #286
3
+ * Fix instrumentation that would report a duration of `0ms` for all DataMapper
4
+ queries. PR #290
5
+ * Finish events when `Appsignal.instrument` encounters a `raise` or a `throw`.
6
+ PR #292
7
+
1
8
  # 2.2.0
2
9
  * Support Ruby 2.4 better. PR #234
3
10
  * Initial setup for documenting the Ruby gem's code. PR #243
@@ -1,18 +1,18 @@
1
1
  ---
2
- version: f16607c
2
+ version: d54a76a
3
3
  triples:
4
4
  x86_64-linux:
5
- checksum: '0479e8b0aeba95360e9fd8cfd7e7f7f4c1a8dfc555f6149c0c35d27593a05193'
6
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/f16607c/appsignal-x86_64-linux-all-static.tar.gz
5
+ checksum: 281d91b060365e05fc2df94eb88b0b8d7f6fde06c439829bdd170f202f5aa5b1
6
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/d54a76a/appsignal-x86_64-linux-all-static.tar.gz
7
7
  i686-linux:
8
- checksum: 3c3c63f26bec0304649cad4fb69410dd6b13313a178f3db7cdeba72b24834715
9
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/f16607c/appsignal-i686-linux-all-static.tar.gz
8
+ checksum: 91e9d317a45d0a5e1a03b5a12480c221182b8f460638532181b58b362941d3d5
9
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/d54a76a/appsignal-i686-linux-all-static.tar.gz
10
10
  x86-linux:
11
- checksum: 3c3c63f26bec0304649cad4fb69410dd6b13313a178f3db7cdeba72b24834715
12
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/f16607c/appsignal-i686-linux-all-static.tar.gz
11
+ checksum: 91e9d317a45d0a5e1a03b5a12480c221182b8f460638532181b58b362941d3d5
12
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/d54a76a/appsignal-i686-linux-all-static.tar.gz
13
13
  x86_64-darwin:
14
- checksum: 853398d93cda5f16edd2a931346f97fedea4c16f729bb987564cfbc29e73ef33
15
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/f16607c/appsignal-x86_64-darwin-all-static.tar.gz
14
+ checksum: f9732af3f4913341d0ec70474d893472fd1bf9720c5cea098a24be92379872aa
15
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/d54a76a/appsignal-x86_64-darwin-all-static.tar.gz
16
16
  universal-darwin:
17
- checksum: 853398d93cda5f16edd2a931346f97fedea4c16f729bb987564cfbc29e73ef33
18
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/f16607c/appsignal-x86_64-darwin-all-static.tar.gz
17
+ checksum: f9732af3f4913341d0ec70474d893472fd1bf9720c5cea098a24be92379872aa
18
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/d54a76a/appsignal-x86_64-darwin-all-static.tar.gz
@@ -119,7 +119,7 @@ static VALUE finish_event(VALUE self, VALUE name, VALUE title, VALUE body, VALUE
119
119
  return Qnil;
120
120
  }
121
121
 
122
- static VALUE record_event(VALUE self, VALUE name, VALUE title, VALUE body, VALUE duration, VALUE body_format, VALUE gc_duration_ms) {
122
+ static VALUE record_event(VALUE self, VALUE name, VALUE title, VALUE body, VALUE body_format, VALUE duration, VALUE gc_duration_ms) {
123
123
  appsignal_transaction_t* transaction;
124
124
  appsignal_data_t* body_data;
125
125
  int body_type;
@@ -461,10 +461,12 @@ module Appsignal
461
461
  # instrumented. Accepted values are {EventFormatter::DEFAULT} and
462
462
  # {EventFormatter::SQL_BODY_FORMAT}, but we recommend you use
463
463
  # {.instrument_sql} instead of {EventFormatter::SQL_BODY_FORMAT}.
464
- # @yield yields the given block of code instrumented in an AppSignal event.
464
+ # @yield yields the given block of code instrumented in an AppSignal
465
+ # event.
465
466
  # @return [Object] Returns the blocks return value.
466
467
  #
467
- # @see .instrument_sql Specific helper for SQL queries.
468
+ # @see Appsignal::Transaction#instrument
469
+ # @see .instrument_sql
468
470
  # @see http://docs.appsignal.com/ruby/instrumentation/instrumentation.html
469
471
  # AppSignal custom instrumentation guide
470
472
  # @see http://docs.appsignal.com/api/event-names.html
@@ -472,9 +474,9 @@ module Appsignal
472
474
  # @since 1.3.0
473
475
  def instrument(name, title = nil, body = nil, body_format = Appsignal::EventFormatter::DEFAULT)
474
476
  Appsignal::Transaction.current.start_event
475
- return_value = yield if block_given?
477
+ yield if block_given?
478
+ ensure
476
479
  Appsignal::Transaction.current.finish_event(name, title, body, body_format)
477
- return_value
478
480
  end
479
481
 
480
482
  # Instrumentation helper for SQL queries.
@@ -22,8 +22,8 @@ module Appsignal
22
22
  # Start logger
23
23
  Appsignal.start_logger
24
24
 
25
- app.middleware.insert_before(
26
- ActionDispatch::RemoteIp,
25
+ app.middleware.insert_after(
26
+ ActionDispatch::DebugExceptions,
27
27
  Appsignal::Rack::RailsInstrumentation
28
28
  )
29
29
 
@@ -278,17 +278,17 @@ module Appsignal
278
278
  name,
279
279
  title || BLANK,
280
280
  body || BLANK,
281
- duration,
282
281
  body_format || Appsignal::EventFormatter::DEFAULT,
282
+ duration,
283
283
  self.class.garbage_collection_profiler.total_time
284
284
  )
285
285
  end
286
286
 
287
287
  def instrument(name, title = nil, body = nil, body_format = Appsignal::EventFormatter::DEFAULT)
288
288
  start_event
289
- r = yield
289
+ yield if block_given?
290
+ ensure
290
291
  finish_event(name, title, body, body_format)
291
- r
292
292
  end
293
293
 
294
294
  class GenericRequest
@@ -1,5 +1,5 @@
1
1
  require "yaml"
2
2
 
3
3
  module Appsignal
4
- VERSION = "2.2.0".freeze
4
+ VERSION = "2.2.1".freeze
5
5
  end
@@ -48,7 +48,7 @@ describe "extension loading and operation" do
48
48
  end
49
49
 
50
50
  it "should have a record_event method" do
51
- subject.record_event("name", "title", "body", 1000, 0, 1000)
51
+ subject.record_event("name", "title", "body", 0, 1000, 1000)
52
52
  end
53
53
 
54
54
  it "should have a set_error method" do
@@ -57,6 +57,7 @@ if DependencyHelper.padrino_present?
57
57
  let(:base) { double }
58
58
  let(:router) { PadrinoClassWithRouter.new }
59
59
  let(:env) { {} }
60
+ # TODO: use an instance double
60
61
  let(:settings) { double(:name => "TestApp") }
61
62
 
62
63
  describe "routes" do
@@ -107,6 +108,7 @@ if DependencyHelper.padrino_present?
107
108
  Appsignal::Transaction::HTTP_REQUEST,
108
109
  request_kind
109
110
  ).and_return(transaction)
111
+
110
112
  expect(Appsignal).to receive(:instrument)
111
113
  .at_least(:once)
112
114
  .with("process_action.padrino")
@@ -11,7 +11,10 @@ if DependencyHelper.rails_present?
11
11
 
12
12
  describe "#initialize_appsignal" do
13
13
  let(:app) { MyApp::Application }
14
- before { allow(app.middleware).to receive(:insert_before).and_return(true) }
14
+ before do
15
+ allow(app.middleware).to receive(:insert_before)
16
+ allow(app.middleware).to receive(:insert_after)
17
+ end
15
18
 
16
19
  describe ".logger" do
17
20
  before { Appsignal::Integrations::Railtie.initialize_appsignal(app) }
@@ -68,8 +71,8 @@ if DependencyHelper.rails_present?
68
71
 
69
72
  describe "Rails listener middleware" do
70
73
  it "adds the Rails listener middleware" do
71
- expect(app.middleware).to receive(:insert_before).with(
72
- ActionDispatch::RemoteIp,
74
+ expect(app.middleware).to receive(:insert_after).with(
75
+ ActionDispatch::DebugExceptions,
73
76
  Appsignal::Rack::RailsInstrumentation
74
77
  )
75
78
  end
@@ -93,8 +96,8 @@ if DependencyHelper.rails_present?
93
96
  let(:enable_frontend_error_catching) { true }
94
97
 
95
98
  it "adds the Rails and JSExceptionCatcher middleware" do
96
- expect(app.middleware).to receive(:insert_before).with(
97
- ActionDispatch::RemoteIp,
99
+ expect(app.middleware).to receive(:insert_after).with(
100
+ ActionDispatch::DebugExceptions,
98
101
  Appsignal::Rack::RailsInstrumentation
99
102
  )
100
103
 
@@ -109,8 +112,8 @@ if DependencyHelper.rails_present?
109
112
  let(:enable_frontend_error_catching) { false }
110
113
 
111
114
  it "adds the Rails middleware, but not the JSExceptionCatcher middleware" do
112
- expect(app.middleware).to receive(:insert_before).with(
113
- ActionDispatch::RemoteIp,
115
+ expect(app.middleware).to receive(:insert_after).with(
116
+ ActionDispatch::DebugExceptions,
114
117
  Appsignal::Rack::RailsInstrumentation
115
118
  )
116
119
 
@@ -568,8 +568,8 @@ describe Appsignal::Transaction do
568
568
  "name",
569
569
  "title",
570
570
  "body",
571
- 1000,
572
571
  1,
572
+ 1000,
573
573
  fake_gc_time
574
574
  ).and_call_original
575
575
 
@@ -587,8 +587,8 @@ describe Appsignal::Transaction do
587
587
  "name",
588
588
  "",
589
589
  "",
590
- 1000,
591
590
  0,
591
+ 1000,
592
592
  fake_gc_time
593
593
  ).and_call_original
594
594
 
@@ -603,22 +603,8 @@ describe Appsignal::Transaction do
603
603
  end
604
604
 
605
605
  describe "#instrument" do
606
- it "should start and finish an event around the given block" do
607
- stub = double
608
- expect(stub).to receive(:method_call).and_return("return value")
609
-
610
- expect(transaction).to receive(:start_event)
611
- expect(transaction).to receive(:finish_event).with(
612
- "name",
613
- "title",
614
- "body",
615
- 0
616
- )
617
-
618
- return_value = transaction.instrument "name", "title", "body" do
619
- stub.method_call
620
- end
621
- expect(return_value).to eq "return value"
606
+ it_behaves_like "instrument helper" do
607
+ let(:instrumenter) { transaction }
622
608
  end
623
609
  end
624
610
 
@@ -298,18 +298,6 @@ describe Appsignal do
298
298
  end.to_not raise_error
299
299
  end
300
300
  end
301
-
302
- describe ".instrument" do
303
- it "should not instrument, but still call the block" do
304
- stub = double
305
- expect(stub).to receive(:method_call).and_return("return value")
306
-
307
- return_value = Appsignal.instrument "name" do
308
- stub.method_call
309
- end
310
- expect(return_value).to eq "return value"
311
- end
312
- end
313
301
  end
314
302
 
315
303
  context "with config and started" do
@@ -848,28 +836,11 @@ describe Appsignal do
848
836
  end
849
837
 
850
838
  describe ".instrument" do
851
- before do
852
- expect(Appsignal::Transaction).to receive(:current).at_least(:once).and_return(transaction)
853
- end
854
-
855
- it "should instrument through the transaction" do
856
- expect(transaction).to receive(:start_event)
857
- expect(transaction).to receive(:finish_event)
858
- .with("name", "title", "body", Appsignal::EventFormatter::DEFAULT)
859
-
860
- result = Appsignal.instrument "name", "title", "body" do
861
- "return value"
839
+ it_behaves_like "instrument helper" do
840
+ let(:instrumenter) { Appsignal }
841
+ before do
842
+ expect(Appsignal::Transaction).to receive(:current).at_least(:once).and_return(transaction)
862
843
  end
863
- expect(result).to eq "return value"
864
- end
865
-
866
- it "should instrument without a block given" do
867
- expect(transaction).to receive(:start_event)
868
- expect(transaction).to receive(:finish_event)
869
- .with("name", "title", "body", Appsignal::EventFormatter::DEFAULT)
870
-
871
- result = Appsignal.instrument "name", "title", "body"
872
- expect(result).to be_nil
873
844
  end
874
845
  end
875
846
 
@@ -878,7 +849,7 @@ describe Appsignal do
878
849
  expect(Appsignal::Transaction).to receive(:current).at_least(:once).and_return(transaction)
879
850
  end
880
851
 
881
- it "should instrument sql through the transaction" do
852
+ it "creates an SQL event on the transaction" do
882
853
  expect(transaction).to receive(:start_event)
883
854
  expect(transaction).to receive(:finish_event)
884
855
  .with("name", "title", "body", Appsignal::EventFormatter::SQL_BODY_FORMAT)
@@ -19,6 +19,9 @@ end
19
19
  Dir[File.join(APPSIGNAL_SPEC_DIR, "support/mocks", "*.rb")].each do |f|
20
20
  require f
21
21
  end
22
+ Dir[File.join(APPSIGNAL_SPEC_DIR, "support/shared_examples", "*.rb")].each do |f|
23
+ require f
24
+ end
22
25
  if DependencyHelper.rails_present?
23
26
  Dir[File.join(DirectoryHelper.support_dir, "rails", "*.rb")].each do |f|
24
27
  require f
@@ -0,0 +1,43 @@
1
+ RSpec.shared_examples "instrument helper" do
2
+ let(:stub) { double }
3
+ before do
4
+ expect(stub).to receive(:method_call).and_return("return value")
5
+
6
+ expect(transaction).to receive(:start_event)
7
+ expect(transaction).to receive(:finish_event).with(
8
+ "name",
9
+ "title",
10
+ "body",
11
+ 0
12
+ )
13
+ end
14
+
15
+ it "records an event around the given block" do
16
+ return_value = instrumenter.instrument "name", "title", "body" do
17
+ stub.method_call
18
+ end
19
+ expect(return_value).to eq "return value"
20
+ end
21
+
22
+ context "with an error raised in the passed block" do
23
+ it "records an event around the given block" do
24
+ expect do
25
+ instrumenter.instrument "name", "title", "body" do
26
+ stub.method_call
27
+ raise "foo"
28
+ end
29
+ end.to raise_error(StandardError, "foo")
30
+ end
31
+ end
32
+
33
+ context "with an error raise in the passed block" do
34
+ it "records an event around the given block" do
35
+ expect do
36
+ instrumenter.instrument "name", "title", "body" do
37
+ stub.method_call
38
+ throw :foo
39
+ end
40
+ end.to throw_symbol(:foo)
41
+ end
42
+ end
43
+ 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: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-03 00:00:00.000000000 Z
12
+ date: 2017-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -339,6 +339,7 @@ files:
339
339
  - spec/support/project_fixture/config/environments/test.rb
340
340
  - spec/support/project_fixture/log/.gitkeep
341
341
  - spec/support/rails/my_app.rb
342
+ - spec/support/shared_examples/instrument.rb
342
343
  - spec/support/stubs/delayed_job.rb
343
344
  homepage: https://github.com/appsignal/appsignal
344
345
  licenses:
@@ -361,7 +362,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
362
  version: '0'
362
363
  requirements: []
363
364
  rubyforge_project:
364
- rubygems_version: 2.6.10
365
+ rubygems_version: 2.6.12
365
366
  signing_key:
366
367
  specification_version: 4
367
368
  summary: Logs performance and exception data from your app to appsignal.com
@@ -457,4 +458,5 @@ test_files:
457
458
  - spec/support/project_fixture/config/environments/test.rb
458
459
  - spec/support/project_fixture/log/.gitkeep
459
460
  - spec/support/rails/my_app.rb
461
+ - spec/support/shared_examples/instrument.rb
460
462
  - spec/support/stubs/delayed_job.rb